home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1998-03-19 | 114.7 KB | 3,121 lines | [ TEXT/MPS ]
# # **************************************************************************** # # File Name: UserInterface.Lib # # Contains: Library of tasks that manipulate some aspect of the Human Interface. # # Written by: KTA, KL, ML, GS et al # # Copyright: © 1993-1996 by Apple Computer, Inc., all rights reserved. # # **************************************************************************** # C h a n g e H i s t o r y (most recent first): # **************************************************************************** # # Vers Date Author Description # ---- -------- ------ --------------------------------------------- # 2.1.114> 5/3/96 MDF TypeStr() - Added gSwitchToUSHook task reference. This will # support Intl request for switching back to the "U.S." script # when pTheString contains precomposed doublebyte characters. # .1.113+> 5/3/96 MDF TypeStr() - check for task reference which will switch to "U.S." # script if InitINTLGlobals() is called in a script. # 2.1.113> 5/1/96 MDF Modified CheckYesNo() and TypeList() tasks. # .1.112+> 5/1/96 MDF Modified CheckYesNo() and TypeList() tasks. # 2.1.112> 2/8/96 JC Changed all window .r (Rect) traits to .b (bound) traits and # changed any window insets to reflect new bound rect. # 2.1.111> 1/2/96 ML DragAcrossScreens, SizeAcrossScreens - pass pSpecifier # into DragWindow call. # .1.110+> 1/2/96 ML DragAcrossScreens, SizeAcrossScreens - pass pSpecifier into # DragWindow call. # 2.1.110> 11/21/95 ML CheckYesNo, DialogDismisser - add support for international # 2.1.19+> 11/21/95 ML CheckYesNo, DialogCheck - add support for international # <2.1.19> 4/24/95 KTA Fixed small bugs in DialogDismisser() and TestWindow(). # <2.1.18> 3/22/95 ML DialogDismisser() - use _MatchBoolean() to check existence of # pSpecifier # <2.1.17> 2/14/95 KTA DragAcrossScreen(), SizeAcrossScreen() - Check to see if a # second monitor exists before matching it. # <2.1.16> 2/10/95 KTA DialogDismisser() - Optimized, removed edittext from # specifiedDialog / TestWindow() - use _MatchBoolean instead of # _collect # <2.1.15> 2/6/95 ML CheckYesNo() - use _MatchBoolean instead of _match # <2.1.14> 1/31/95 KTA Fixed some scrollbar problems in GetVHScrollbars(), # WindowFunction(), and TestWindow(). # <2.1.13> 1/19/95 KTA Changed the name of ExceptionHandler() to ExceptionDispatcher(). # <2.1.12> 1/10/95 KTA TestWindow(), ResetWindwow() - Fixed problem - weren't # accounting for the h trait for scroll bars. # <2.1.11> 1/10/95 KTA WindowFunction() - Added new task, resetWindowFunctionList(), # which removes tests specified by global gDoWindowList # <2.1.10> 12/21/94 KTA DragWindow() - Removed errant {str1} # <2.1.9> 12/14/94 ML Cleaner error handling in Dialogcheck() # <2.1.8> 11/28/94 ML Correct syntax errors # <2.1.7> 11/22/94 ML Added error handling support # <2.1.6> 11/8/94 KTA UnCoverWindow() - Updated so it is possible to pass in # pFrontWindow. # <2.1.5> 9/21/94 KTA DialogHandler() - Check to see if there was any statictext # before concatenating strings. # <2.1.4> 9/21/94 KTA ResetWindow() - Fixed trying to reset scrollbars when no # thumbnail (0,0) # <2.1.3> 9/21/94 KTA Fix syntax error in SelectPopupMenuItem(). # <2.1.2> 9/20/94 KTA Comments # <2.1.1> 9/20/94 KTA Added new task - SelectPopUpMenuItem() # <2.1.0> 9/20/94 KTA SelectRadioButton(), SelectCheckBox() - Select by title and # ordinality instead of just ordinality. # 2.0.211> 6/9/94 ML CheckYesNo() - used wildcard for apostrophe in "Don't Save" # 2.0.210> 5/12/94 KTA DialogHandler() - Changed the dialog window to either a # movablemodal or a dialog. # <2.0.29> 4/28/94 ML marked # <2.0.28> 4/26/94 KTA Fixed problem sizing and dragging across multiple monitors. # <2.0.27> 4/13/94 KTA MoveMouse() - variable named wrong. # <2.0.26> 3/24/94 KTA Added new dialogHandler() and DialogDismisser(). # <2.0.25> 3/16/94 KTA Fixed bug in MoveRelativeToWindow() when pMouseDown was 1, but # list of points was passed in. # <2.0.24> 3/16/94 KTA Added new method for MoveRelativeToWindow(). # <2.0.23> 3/15/94 KTA Added ordinality to output for UserInterface tasks. # <2.0.22> 12/16/93 KTA SizeWindow() - fixed bug where trying to size window smaller # than 20 pixels # <2.0.21> 12/2/93 KTA DialogCheck() - supports button descriptors, TypeStr() added # gTypeStrOverRide. # <2.0.20> 11/19/93 NAGA modify TCS format # <2.0.19> 11/19/93 KTA A couple of changes for INTL and Performance # <2.0.18> 11/11/93 KTA DialogCheck() - If no pFindStaticText is passed in, it will work # on any dialog. # <2.0.17> 9/22/93 KTA Removed a projector error message. # <2.0.16> 9/22/93 KTA Changed gEndTimer task references to reflect the task in which # the references are located. # <2.0.15> 9/13/93 KTA SelectButton(), SelectRadioButton(), selectCheckBox - added # support for selecting by ordinality. # <2.0.14> 9/13/93 KTA Updated TestLevel specification and DismissDialog() now supports # KeyEq('.'). # <2.0.13> 9/9/93 KTA SelectMenuItem(), KeyEq() - Changed output line so it does not # say 'About to …' # <2.0.12> 9/7/93 KTA KeyEq() - Added pOtherKey := 3 (controlkey). # <2.0.11> 9/1/93 KTA Parameter Updates # <2.0.10> 9/1/93 KTA More header updates - Window section # <2.0.9> 9/1/93 KTA Updated task headers and parameters. # <2.0.8> 8/25/93 KTA Added support for parity checking the TCS stack. # <2.0.7> 7/30/93 KTA Updates to DismissDialog(), DialogHandler(), and DialogCheck(), # also updated a couple of descriptors that were still contained # within lists. # <2.0.6> 7/23/93 KTA CloseWindow() - needed a wait(2) and call IsStandardFile(). # <2.0.5> 7/22/93 KTA FindWindow() - if specifier is a descriptor needed a Dammit # operator (!) # <2.0.4> 7/20/93 KTA A couple of more changes to support FindWindow(). # <2.0.3> 7/19/93 KTA Updated for FindWindow to handle descriptors. # <2.0.2> 7/7/93 KTA Changed DismissDialog() so it would properly verify whether # dialog was dismissed. # <2.0.1> 7/6/93 KTA Performance support and other misc. changes. # <1+> 5/21/93 NAGA Adding header and porting old files to follow new standards # # **************************************************************************** # ######################################################################## # External libraries #======================================================================= Libraries "Geometry.lib","String.Lib","Output.lib","TCS.lib", "StandardFile.lib", "ExceptionHandling.Lib"; #======================================================================= # Menu related tasks: #======================================================================= ######################################################################## # SelectMenuItem(pMenu1, pMenu2, pMenu3) #======================================================================= # Author: KTA # Description: Selects the menu item by its title or ordinality. # All parameters are expected to be the same type. # Parameters: pMenu1 := Menu item to be selected. # pMenu2 := Menu name if non-hier menu and # Level 2 menu item if hier menu. # pMenu3 := "" if non-hier menu. # Menu name if hier menu. # Returns: menuTitle - MenuItem name that selection was successful # 0 - Couldn't select menu item # Notes: It is not mandatory to specify input parameters 'pMenu2' # or 'pMenu3'. In that case, default value, "", # will be used. #======================================================================= # History: # KTA 7/6/93 Performance support: Call (gBeginTimer); # KTA 7/6/93 Readded regularExpression support # KTA 9/9/93 Changed output line so it does not say 'About to …' # KTA 9/21/93 Changed gBeginTimer to gPreSelectMenuItemHook, gPostSelectMenuItemHook # KTA 3/15/94 Added outputting the menuitem ordinality. # ML 11/22/94 Added error handling support ######################################################################## TASK SelectMenuItem(pMenu1, pMenu2 := "", pMenu3 := "") begin returnVal := 0; #println "SelectMenuitem∂( ",pMenu1,',',pMenu2,',',pMenu3,"∂)"; if not (_matchBoolean ([window o:1 s:Dialog c:0 g:0 z:0])) begin if ((Typeof(pMenu1) = 'string') or (Typeof(pMenu1) = 'regularExpression')) begin if (pMenu3 = "") # Match non-hier menus ourMenuItem := _match ([menuItem t: pMenu1 m:[menu t: pMenu2]]); else # Match hier menus ourMenuItem :=_match ([menuItem t:pMenu1 m:[menuitem t:pMenu2 m:[menu t:pMenu3]]]); end; else begin if not(pMenu3) # Match non-hier menus ourMenuItem := _match ([menuItem o:pMenu1 m:[menu o:pMenu2]]); else # Match hier menus ourMenuItem := _match ([menuItem o:pMenu1 m:[menuitem o:pMenu2 m:[menu o:pMenu3]]]); end; if (ourMenuItem) # Not there begin menuTitle := ourMenuItem.t; menuOrd := ourMenuItem.o; if (ourMenuItem.e) # enabled begin LogStr("Selecting the '{menuTitle}' menu item (ordinality '{menuOrd}')"); if (global gMacstiming) and (global gPreSelectMenuItemHook) # possible changes to collect macstime data accurately # after the menu item is selcted Finder doesn't get time so the AppleEvent # can be parsed and executed by the MacsTime CDEV - So we need to start # MacsTime before the menu select Call (gPreSelectMenuItemHook); _select (ourMenuItem,1); if not(gMacsTiming) and (global gPostSelectMenuItemHook) Call (gPostSelectMenuItemHook); returnVal := menuTitle; end; else begin LogStr("!@#$% Menu item '{menuTitle}' (ordinality '{menuOrd}') is not enabled to select."); end; end; else LogStr("!@#$% Could not find menu item '{pMenu1}' to select"); end; else begin LogStr("!@#$% Dialog present can't select menuItems"); DialogCheck(, 1); # Attempt to dismiss the dialog end; return(returnVal); end; # SelectMenuItem() ######################################################################## # SelectPopUpMenuItem(pPopUpMenuItemSpecifer, pPopupMenuSpecifier) #======================================================================= # Author: KTA # Description: Selects the popUp menu item <pPopUpMenuItemSpecifer> # contained in the popUp menu <pPopupMenuSpecifier>. # Parameter types can be mixed. # Parameters: pPopUpMenuItemSpecifer := PopUp menu item to be selected. # Can be string, integer, descriptor # pPopupMenuSpecifier := PopUp menu which contains <pPopUpMenuItemSpecifer>. # Can be string, integer, descriptor # Returns: 1 - successful # 0 - Couldn't select menu item # Notes: Only works with Popup menuitems that VU recognizes. #======================================================================= # History: # KTA 9/20/94 Created # ML 11/22/94 Added error handling support ######################################################################## TASK SelectPopUpMenuItem(pPopUpMenuItemSpecifer, pPopupMenuSpecifier) begin returnVal := 0; MenuSpecifierType := Typeof(pPopupMenuSpecifier); MenuItemSpecifierType := Typeof(pPopUpMenuItemSpecifer); if (MenuItemSpecifierType = 'string') and (MenuSpecifierType = 'string') thePopup := _match ([menuItem t:pPopUpMenuItemSpecifer m:[ popup t:pPopupMenuSpecifier]]); else if (MenuItemSpecifierType = 'string') and (MenuSpecifierType = 'integer') thePopup := _match ([menuItem t:pPopUpMenuItemSpecifer m:[ popup o:pPopupMenuSpecifier]]); else if (MenuItemSpecifierType = 'integer') and (MenuSpecifierType = 'string') thePopup := _match ([menuItem o:pPopUpMenuItemSpecifer m:[ popup t:pPopupMenuSpecifier]]); else if(MenuItemSpecifierType = 'integer') and (MenuSpecifierType = 'integer') thePopup := _match ([menuItem o:pPopUpMenuItemSpecifer m:[ popup o:pPopupMenuSpecifier]]); else if(MenuItemSpecifierType = 'descriptor') thePopup := _match ( pPopUpMenuItemSpecifer); else if(MenuSpecifierType = 'descriptor') thePopup := _match ( pPopupMenuSpecifier); if(thePopup) begin if(thePopup.e) begin PopUPMenuTitle := thepopup.m.t; PopUPMenuOrd := thepopup.m.o; PopUPItemTitle := thePopup.t; PopUPItemOrd := thePopup.o; _select (thePopup); LogStr( "Selecting popup menuitem titled '{PopUPItemTitle}' (ordinality '{PopUPItemOrd}') from popup menu '{PopUPMenuTitle}' ord '{PopUPMenuOrd}'"); returnVal := 1; end; else LogStr("!@#$% PopUp menu item '{PopUPItemTitle}' (ordinality '{PopUPItemOrd}') in popup menu '{PopUPMenuTitle}' (ord '{PopUPMenuOrd}') is not enabled to select."); end; else LogStr("!@#$% Could not find popupmenu item '{pPopUpMenuItemSpecifer}' to select from '{pPopupMenuSpecifier}' popup menu"); return(returnVal); end; ######################################################################### # FindMenu(pTheMenuItem) #======================================================================= # Author: KTA # Description: Returns the Menu(s) in which <pTheMenuItem> is contained. # Parameters: pTheMenuItem := Title of the menuitem to be searched for. # Returns: 0 - Can't match <pTheMenuItem>. # {theMenu,""} - for a nonHierarchical menu. # {theHMenuItem, theMenu} - if its hierarchical. # Example: MyMenu := FindMenu('Paste'); #======================================================================= # History: # ML 11/22/94 Added error handling support ######################################################################### TASK FindMenu(pTheMenuItem) begin MenuName := _match ([menuitem t:pTheMenuItem]); if (MenuName) begin IsMenu := descType(MenuName.m); if (IsMenu = 'menu') begin theMenu := MenuName.m.t; Return({theMenu,""}); end; else If (IsMenu = 'menuItem') begin theHMenuItem := MenuName.m.t; try match [menuItem t:pTheMenuItem m:[menuitem t:theHMenuItem m:[menu t:?theMenu]]]; catch theError ExceptionDispatcher(theError); Return({theHMenuItem, theMenu}); end; end; else Return(0); end; # FindMenu() ######################################################################### # KeyEq(pKeyEquiv,pOtherkey, pNumTimes) #======================================================================== # Author: KTA # Description: This routine will select the Keyboard Equiv <pKeyEquiv> # Parameters: pKeyEquiv - string holding character to be typed with # command key down. # pOtherkey - integer - representing special keys to hold # down in conjunction with the command key # 1 - Shift key # 2 - Option key # 3 - Control key # pNumTimes - integer - representing number of times to type keyEq. # Returns: None # Examples: KeyEq("q"); #======================================================================== # History: # KTA 7/2/93 Added pNumTimes parameter for number of times to type KeyEq. # KTA 7/6/93 Performance support: Call (gBeginTimer); # KTA 9/7/93 Added pOtherKey := 3 (controlkey) # KTA 9/9/93 Changed output line so it does not say 'About to …' # KTA 9/21/93 Changed gBeginTimer to gPreKeyEqHook # ML 11/22/94 Added error handling support ######################################################################### TASK KeyEq(pKeyEquiv, pOtherkey := 0, pNumTimes := 1) begin KeyList := { '',''}; if (pOtherkey =1) KeyList := {ShiftKey,'-Shift'}; else if (pOtherkey = 2) KeyList := {Optionkey,'-Option'}; else if (pOtherkey = 3) KeyList := {Controlkey,'-Control'}; WhichKey := KeyList[2]; LogStr("Pressing the ∂('{pKeyEquiv}'∂) key and the Command{WhichKey} key {pNumTimes} times"); _pressKey ({ commandKey,KeyList[1]}); For i := 1 to pNumTimes begin if (global gPreKeyEqHook) Call (gPreKeyEqHook); _type ({ pKeyEquiv }); end; _releaseKey ({ commandKey,KeyList[1] }); end; # KeyEq() #======================================================================= # Window related tasks: #======================================================================= # Description: This section contains VU code for running tests on the # basic controls of a window. # # *** The main task in this section is TestWindow(). It is used to # perform a number of window test automatically. # # The window related tasks in this library are grouped in the # following logical order: # # TestWindow(pSpecifier, pFunctionList, pRestoreWindow, pNumTimes, pDragXY) # WindowFunction(pSpecifier, pTheFunction, pDragXY, pDestinationPoint) # DragAcrossScreens(pSpecifier,pDragXY) # SizeAcrossScreens(pSpecifier, pDragXY) # AdjustRectToScreen(pTheRect) # CoverCompletely (pFirstWindow, pSecondWindow) # ResetWindow(pTheWindow) # SelectWindow(pSpecifier) # UnCoverWindow(pSpecifier, pFrontWindow) # DragWindow(pHorizontalPixels, pVerticalPixels, pSpecifier,pAbsolutely) # SizeWindow(pPixelsWide, pPixelsHigh, pSpecifier, pAbsolutely) # ZoomWindow(pSpecifier) # CloseWindow(pHowClose,pOverWrite,pSpecifier,pNewDocName) # ScrollWindow(pWhichScrollBar,pDesirePosition,pMaxPosition) # GetVHScrollBars() # CloseAllWindows() # FindWindow(pSpecifier) # GetRandomPointsRelativeToWindow(pInset, pSpecifier, pNumPts) # # # # # # # # Copyright Apple Computer, Inc. 1985-1990 # All rights reserved # #======================================================================== # History: # ######################################################################### ######################################################################### # TestWindow(pSpecifier,pFunctionList,pRestoreWindow,pNumTimes,pDragXY) #======================================================================= # Author: NJV # # Description: Performs the specified functions as defined in the input # parameter pFunctionList. If pFunctionList is not passed, # or is passed as 0, then the following operations are # performed on the window specified by input parameter # pSpecifier. The default behavior will perform the # following behaviors on the frontmost window* (see *NOTE). # Listed below is the list of function numbers and a brief # description of what that particular function does: # # #0 Complete Window Test # Performs functions 1 through 17 # (17 is done twice - zoom & zoom back) # #1 Resize to random width and height. # #2 Attempt resize to 20,20 (should not allow it) # #3 Scroll the vertical scroll bar to random location. # #4 Scroll the vertical scroll bar to end location. # #5 Scroll the vertical scroll bar to beginning location. # #6 Scroll the vertical scroll bar to original location. # #7 Scroll the horizontal scroll bar to random location. # #8 Scroll the horizontal scroll bar to end location. # #9 Scroll the horizontal scroll bar to beginning location. # #10 Scroll the horizontal scroll bar to original location. # #11 Resize window to largest possible and then # #12 Resize back to smallest window size # #13 Size window across screen border to second screen # (if 2 screens) and back # #14 Drag window across screen border and back # #15 Drag random location and back to original location # #16 Drag window back to original location. # #17 Zoom. # #18 Complete Window Size Test # Performs functions 1,2,11,12, and 13 # #19 Complete Window Scroll Test # Performs functions 3,4,5,6,7,8,9, and 10 # #20 Complete Window Drag Test # Performs functions 14,15, and 16 # #21 Complete Window Zoom Test # Performs function 17 twice (zoom - zoom back) # #22 A More Complete Window Scroll Test # Performs functions 2,3,4,5,6,7,8,9, and 10. # This is the same as #19 except it sizes the # window to the smallest possible size. This # is better in that it is more likely for the # scrollbars to be active. # #23 A More Complete Window Drag Test # Performs functions 2,14,15, and 16 # This is the same as #20 except it sizes the # window to the smallest possible size. This # is better in that it is more likely for the # window to be able to be dragged across screen # boundaries. # # Parameters: pSpecifier - Title or Ordinality or partial window descriptor # of window to be tested # If this parameter is not passed, default # behavior of Tasks will be used (generally the # frontmost window - see *NOTE below) # # pFunctionList - A list containing the functions to be # executed and the number of times to exercize # each function. The functions will be executed # in the order that they are defined. The default # is to execute all tests once. The pFunctionList # parameter can have the following formats: # # integer: # Number of a single test to run once. # Functions are numbered above. # 0 to execute full sequence once. # # list of integers: # A list of test numbers to run - # each test will be run once and # in the same order that they appear # in the list. # # list of lists: # A list of {test#,#times} lists # where test# is the number of the # test and #times is the number of # times to execute that test. Each # list will be processed in order. # If an item in the main list is an # integer and not a list, that test # number will be executed once. # # pRestoreWindow - 1 to restore window to original size, # location, and scrollbar status. # 0 not to restore window # # pNumTimes - integer for number of times to execute test # # pDragXY - Upper Left-Top corner to drag window to # # Returns: 0 - Couldn't find specified window # 1 - Executed OK # # Assumptions: None # #======================================================================== # History: # KTA 1/10/95 Added resetWindowFunctionList() which removes tests is # specified by global gDoWindowList # KTA 1/10/95 Fixed problem - weren't accounting for the h trait for scroll bars. # KTA 1/31/95 Fixed problem - should have been the e trait not the h trait # ML 2/6/95 _MatchBoolean instead of _collect to first check for scrollbars # KTA 2/24/95 hScroll and vScroll were assigned to the wrong trait (thnx Mona) # JC 2/6/96 Changed all window .r (Rect) traits to .b (bound) traits. ######################################################################### TASK TestWindow(pSpecifier := 0, pFunctionList := 0, pRestoreWindow := 0, pNumTimes := 1, pDragXY := {0,20}) begin if (global gScreenInset) pDragXY := {gScreenInset[1], gScreenInset[2]}; global gOrigScrollBars := 0; # default to scrollbars at beginning returnVal := 0; # get the window's original status - if we can't find it, return 0 originalWindowDesc := FindWindow(pSpecifier); if (originalWindowDesc) begin # set all original window variable information originalOrd := originalWindowDesc.o; if (originalOrd <> 1) originalWindowDesc := SelectWindow(pSpecifier); originalOrd := originalWindowDesc.o; theTitle := originalWindowDesc.t; oldRect := originalWindowDesc.b; theDesc := [window t:theTitle o:originalOrd]; # Partial window descriptor # and scroll bar positions if (_matchBoolean ([scrollbar w:[window t:theTitle o:originalOrd]]!)) begin ScrollBars := _collect ([scrollbar w:[window t:theTitle o:originalOrd]]!,1); if (card ScrollBars >= 2) begin hscroll := ScrollBars[1]; vscroll := ScrollBars[2]; end; else if (card ScrollBars = 1) begin hscroll := ScrollBars[1]; vscroll := [scrollBar s:{ 0, 0 } e:false]; end; if (hscroll.e) and not(hscroll.s = { 0, 0 }) horizontalscroll := hscroll.s; if (vscroll.e) and not(vscroll.s = { 0, 0 }) Verticalscroll := vscroll.s; if(horizontalscroll) or (Verticalscroll) begin if(horizontalscroll) and (Verticalscroll) gOrigScrollBars := {Verticalscroll,horizontalscroll}; else if (Verticalscroll) gOrigScrollBars := {Verticalscroll,0}; else if (horizontalscroll) gOrigScrollBars := {0, horizontalscroll}; end; else gOrigScrollBars := 0; end; # if pFunctionList = 0, run default behavior if (pFunctionList = 0) begin println; println "==========================================================================="; LogStr("Starting Complete Window Test..."); #pFunctionList := {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,17}; pFunctionList := {17,17,12,11,1,3,4,5,6,7,8,9,10,13,14,15,11}; end; # first, drag the window onto screen to assure more success at functions # Drag it to the desired location (if needed) if not ((tempRect[1] = pDragXY[1]) and (tempRect[2] = pDragXY[2])) if global gDoWindowList[3] # if dragging is available DragWindow(pDragXY[1],pDragXY[2],theDesc,1); # Call with partial window descriptor #Remove any tests which are not supposed to run according to the global gDoWindowList pFunctionList := resetWindowFunctionList(pFunctionList); for iterationNum := 1 to pNumTimes do begin # Now perform our test(s) if (TypeOf(pFunctionList) = "integer") begin # it's a single test WindowFunction(theDesc, pFunctionList, pDragXY, oldRect); end; else begin # it's a list of tests for currentFunction := 1 to card pFunctionList do begin theFunction := pFunctionList[currentFunction]; if (TypeOf(theFunction) = "list") begin for tempCount := 1 to theFunction[2] begin if (WindowFunction(theDesc,theFunction[1],pDragXY,oldRect)) returnVal := 1; end; end; else begin if (WindowFunction(theDesc,theFunction,pDragXY,oldRect)) returnVal := 1; end; end; end; end; if (pRestoreWindow) ResetWindow(originalWindowDesc); returnVal := 1; end; else LogStr("Couldn't find specified window for TestWindow"); return(returnVal); end; # TestWindow() ######################################################################### # WindowFunction(pSpecifier, pTheFunction, pDragXY,pDestinationPoint) #======================================================================= # Author: NJV # Description: Performs the specified function defined in the input # parameter pTheFunction to the window specified by pSpecifier. # Listed below is the list of function numbers and a brief # description of what that particular function does: # # #1 Resize to random width and height. # #2 Attempt resize to 20,20 (should not allow it) # #3 Scroll the vertical scroll bar to random location. # #4 Scroll the vertical scroll bar to end location. # #5 Scroll the vertical scroll bar to beginning location. # #6 Scroll the vertical scroll bar to original location. # #7 Scroll the horizontal scroll bar to random location. # #8 Scroll the horizontal scroll bar to end location. # #9 Scroll the horizontal scroll bar to beginning location. # #10 Scroll the horizontal scroll bar to original location. # #11 Resize window to largest possible # #12 Resize back to smallest window size # #13 Size window across screen border to second screen # (if 2 screens) and back # #14 Drag window across screen border and back # #15 Drag window to random location. # #16 Drag window to location specified by pDestinationPoint. # #17 Zoom. # #18 Complete Window Size Test # Performs functions 1,2,11,12, and 13 # #19 Complete Window Scroll Test # Performs functions 3,4,5,6,7,8,9, and 10 # #20 Complete Window Drag Test # Performs functions 14,15, and 16 # #21 Complete Window Zoom Test # Performs function 17 twice (zoom - zoom back) # #22 A More Complete Window Scroll Test # Performs functions 2,3,4,5,6,7,8,9, and 10 # This is the same as #19 except it sizes the # window to the smallest possible size. This # is better in that it is more likely for the # scrollbars to be active. # #23 A More Complete Window Drag Test # Performs functions 2,14,15, and 16 # This is the same as #20 except it sizes the # window to the smallest possible size. This # is better in that it is more likely for the # window to be able to be dragged across screen # boundaries. # # Parameters: pSpecifier - Title of window to be tested # # pTheFunction - The number of the test to run # # pDragXY - Left-Top point (list of {left,top}) to drag # window to. (used if pTheFunction = 13 or 14) # # pDestinationPoint - Left/Top point (list of {left,top}) of # original window (used if pTheFunction = 16) # # Returns: 0 - Couldn't perform specified Task # 1 - Executed OK # # Assumptions: None. # # *NOTE: The TestWindow() function provides much more versatility # than this routine. WindowFunction is called by TestWindow. #======================================================================== # History: # ML 11/22/94 Added error handling support # KTA 1/10/95 Added resetWindowFunctionList() which removes tests is # specified by global gDoWindowList # KTA 1/31/95 Check scrollbars to ensure they are enabled before scrolling # JC 2/6/96 Changed all window .r (Rect) traits to .b (bound) traits. # JC 2/6/96 Changed "inset := { 0,20,0,0};" to "inset := { 0,0,0,0};". ######################################################################### TASK WindowFunction(pSpecifier, pTheFunction, pDragXY, pDestinationPoint) begin if (global gScreenInset) inset := gScreenInset; else inset := { 0,0,0,0}; ##use to be inset := { 0,20,0,0}; # if the user wants a multiple function (#18-#23), set FunctionList # accordingly if ((pTheFunction >= 18) and (pTheFunction <= 23)) begin # reset FunctionList if (pTheFunction = 18) begin println; println "==========================================================================="; LogStr("Starting Complete Window Size Test..."); FunctionList := {1,2,11,12,13}; end; else if (pTheFunction = 19) begin println; println "==========================================================================="; LogStr("Starting Complete Window Scroll Test..."); FunctionList := {3,4,5,6,7,8,9,10}; end; else if (pTheFunction = 20) begin println; println "==========================================================================="; LogStr("Starting Complete Window Drag Test..."); FunctionList := {14,15,16}; end; else if (pTheFunction = 21) begin println; println "==========================================================================="; LogStr("Starting Complete Window Zoom Test..."); FunctionList := {17,17}; end; else if (pTheFunction = 22) begin println; println "==========================================================================="; LogStr("Starting Complete Window Scroll Test - Will Shrink Window First..."); FunctionList := {2,3,4,5,6,7,8,9,10}; end; else if (pTheFunction = 23) begin println; println "==========================================================================="; LogStr("Starting Complete Window Drag Test - Will Shrink Window First..."); FunctionList := {2,14,15,16}; end; #Remove any tests which are not supposed to run according to the global gDoWindowList FunctionList := resetWindowFunctionList(FunctionList); # now execute each test using recursion noError := 1; # no errors yet for each item in FunctionList begin if not (WindowFunction(pSpecifier,item,pDragXY,pDestinationPoint)) foundError := 1; end; return(foundError); end; if (pTheFunction = 1) #1 Resize to random width and height. return(SizeWindow('random','random',pSpecifier)); else if (pTheFunction = 2) #2 Attempt resize to 20,20 (should not allow it) return(SizeWindow(20,20,pSpecifier)); else if ((pTheFunction >= 3) and (pTheFunction <= 10)) begin # get the old value of the scroll bars to replace scrollbars as they were found. theScrollBars := GetVHScrollBars(); vertical := theScrollBars[1]; horizontal := theScrollBars[2]; oldVertical := vertical.s; oldHorizontal := horizontal.s; if (pTheFunction = 3) and (vertical.e) #3 Scroll the vertical scroll bar to random location. return(ScrollWindow('V')); else if (pTheFunction = 4) and (vertical.e) #4 Scroll the vertical scroll bar to end location. return(ScrollWindow('V',1,1)); else if (pTheFunction = 5) and (vertical.e) #5 Scroll the vertical scroll bar to beginning location. return(ScrollWindow('V',0,1)); else if (pTheFunction = 6) and (vertical.e) #6 Scroll the vertical scroll bar to original location. return(ScrollWindow('V',oldVertical[1],oldVertical[2])); else if (pTheFunction = 7) and (horizontal.e) #7 Scroll the horizontal scroll bar to random location. return(ScrollWindow('H')); else if (pTheFunction = 8) and (horizontal.e) #8 Scroll the horizontal scroll bar to end location. return(ScrollWindow('H',1,1)); else if (pTheFunction = 9) and (horizontal.e) #9 Scroll the horizontal scroll bar to beginning location. return(ScrollWindow('H',0,1)); else if(horizontal.e) #10 Scroll the horizontal scroll bar to original location. return(ScrollWindow('H',oldHorizontal[1],oldHorizontal[2])); end; else if (pTheFunction = 11) begin #11 Resize window to largest possible # Match to get new rect theWind := FindWindow(pSpecifier); if not (theWind) return(0); else newRect := theWind.b; # get screen coordinates try match [screen r:?theScreenRect m:true]!; catch theError ExceptionDispatcher(theError); #11 Resize window to largest possible return(SizeWindow(theScreenRect[3]-newRect[1]-inset[3],theScreenRect[4]-newRect[2]-inset[4],pSpecifier)); #11 end; else if (pTheFunction = 12) #12 Resize to smallest window size return(SizeWindow(20,20,pSpecifier)); #12 else if (pTheFunction = 13) #13 Size window across screen border to second screen (if 2 screens) and back begin origWind := findWindow(pSpecifier); theReturn := SizeAcrossScreens(pSpecifier,pDragXY); #13 if(theReturn) begin DragWindow(origWind.b[1],origWind.b[2],pSpecifier); SizeWindow(origWind.b[3]-origWind.b[1],origWind.b[4]-origWind.b[2],pSpecifier); end; return(theReturn); end; else if (pTheFunction = 14) #14 Drag window across screen border and back begin origWind := findWindow(pSpecifier); theReturn := DragAcrossScreens(pSpecifier,pDragXY); #14 if(theReturn) DragWindow(origWind.b[1],origWind.b[2],pSpecifier); return(theReturn); end; else if (pTheFunction = 15) #15 Drag random location. return(DragWindow('RandomReturn','Random',pSpecifier)); #15 else if (pTheFunction = 16) #16 Drag window back to original location. return(DragWindow(pDestinationPoint[1],pDestinationPoint[2],pSpecifier)); #16 else if (pTheFunction = 17) #17 Zoom. return(ZoomWindow(pSpecifier)); #17 else LogStr("!@#$% - scriptor error - Unknown Function Number ∂"{pTheFunction}∂" passed to WindowFunction()"); return(0); end; ######################################################################### # ResetWindowFunctionList(pFunctionList) #======================================================================== # Author: KTA # Description: This routine takes a window functionlist as a parameter and removes # any test which are specified as not available by the gDoWindowList global. # Parameters: pFunctionList - Initial function list # global gDoWindowList := {1,1,1,1}; # Set each element to 1 or 0. Flag for performing DoWindows tests as follows: # Element: 1 - Sizing # 2 - Scrolling # 3 - Dragging # 4 - Zooming # Returns: Functiuon list after remove tests that aren't supported. # Examples: FunctionList := ResetWindowFunctionList({1,2,11,12,16,17}); #======================================================================== # History: # KTA 1/10/95 Created ######################################################################### task ResetWindowFunctionList(pFunctionList) begin global gDoWindowList; if(TypeOf(pFunctionList) = 'integer') pFunctionList := {pFunctionList}; WindowTests := {{'Size', 1, {1,2,11,12,13}}, {'Scroll',2,{3,4,5,6,7,8,9,10}}, {'Drag', 3, {14,15,16}}, {'Zoom',4,{17}}}; for each testType in WindowTests begin numItems := Card(pFunctionList); newFunctionList := {}; if not(gDoWindowList[testType[2]]) begin for i := 1 to numItems begin if not(isMember(pFunctionList[i], testType[3])) begin thePos := card(newFunctionList)+1; newFunctionList[thePos] := pFunctionList[i]; end; end; pFunctionList := newFunctionList; numItems := Card(pFunctionList); newFunctionList := {}; end; end; return(pFunctionList); end; ######################################################################### # DragAcrossScreens(pSpecifier,pDragXY) #======================================================================== # Author: NJV # Description: If there are two screens present, this task will drag # the window specified by <pSpecifier> so that half of the # window is on the first screen and half of the window # is on the second screen. # Parameters: pSpecifier - title of window to drag # pDragXY - a list of two co-ordinates (left-top) pixel # to drag window to (i.e.{0,20} to avoid menu bar # on main screen). # Returns: 1 - successful # 0 - unsuccessful # Examples: DragAcrossScreens("Untitled",{0,20}). # Assumptions: None #======================================================================== # History: # KTA 8/24/93 TCS stack parity check # ML 11/22/94 Added error handling support # KTA 2/14/95 Check to see if a second monitor exists before matching it. # ML 1/2/96 pass pSpecifier into DragWindow call # JC 2/6/96 Changed all window .r (Rect) traits to .b (bound) traits. ######################################################################### TASK DragAcrossScreens(pSpecifier,pDragXY) begin returnVal := 0; failStr := ''; # get screen information s1 := _match ([screen m:true]!, 1); if(_MatchBoolean([screen m:false])) s2 := _match ([screen m:false]!, 1); wind := FindWindow(pSpecifier); TCSStart({ 2, global kTCSetUIWindowDrag },"DragAcrossScreens"); if (s2 and s1 and wind) begin # get half of the window height and half of the window width hWidth := ((wind.b[3] - wind.b[1])/2); hHeight := ((wind.b[4] - wind.b[2])/2); # assign various sides of screens to easier and shorter variables l1 := s1.r[1]; r1 := s1.r[3]; t1 := s1.r[2]; b1 := s1.r[4]; l2 := s2.r[1]; r2 := s2.r[3]; t2 := s2.r[2]; b2 := s2.r[4]; # determine if screen2 is to left or right of main screen if ((r2 = l1) or (l2 = r1)) begin if (t1 > t2) Dy := t1 + pDragXY[2]; else Dy := t2; if (l1 < l2) Dx := l2 - hWidth; else Dx := l1 - hWidth; end; # must be above or below main screen else begin if (l1 > l2) Dx := l1; else Dx := l2; if (t1 < t2) Dy := t2 - hHeight; else Dy := t1 - hHeight; end; LogStr("Dragging window across screen borders..."); returnVal := DragWindow(Dx,Dy,pSpecifier); end; else if not (s2) failStr := "Note: Cannot drag across screens because the target doesn't have two monitors"; else failStr := "Something not here couldn't DragAcrossScreens"; # - return unsuccessful if not(returnVal) TCSReturn := -1; # Feature not available else TCSReturn := 1; TCSEnd({ 2, global kTCSetUIWindowDrag }, TCSReturn,failStr); if(failStr) LogStr(failStr); return(returnVal); end; # DragAcrossScreens() ######################################################################### # SizeAcrossScreens(pSpecifier,pDragXY) #======================================================================== # Author: NJV # Description: If there are two screens present, this task will size # the window specified by <pSpecifier> (if there's a grow box) # so half of the window is on the first screen and half of # the window is on the second screen. # Parameters: pSpecifier - Descriptor of the window to size. # pDragXY - a list of two co-ordinates (left-top) pixel # to drag window to (i.e.{0,20} to avoid menu bar # on main screen). # Returns: 1 - successful # 0 - unsuccessful # Examples: SizeAcrossScreens("myWindow",{0,20}). # Assumptions: None #======================================================================== # History: # KTA 8/24/93 TCS stack parity check # ML 11/22/94 Added error handling support # KTA 2/14/95 Check to see if a second monitor exists before matching it. # ML 1/2/96 pass pSpecifier into DragWindow call # JC 2/6/96 Changed all window .r (Rect) traits to .b (bound) traits. ######################################################################### TASK SizeAcrossScreens(pSpecifier, pDragXY) begin # BUG - if second screen is above or below main screen, the following error occurs, # but routine still works # size [window … ] w: horizontal coordinate off bounds returnVal := 0; failStr := ''; # get screen information s1 := _match ([screen m:true]!, 1); if(_MatchBoolean([screen m:false])) s2 := _match ([screen m:false]!, 1); wind := FindWindow(pSpecifier); TCSStart({ 2, global kTCSetUIWindowSize }, "SizeAcrossScreens"); if (s2 and s1 and wind) begin # determine smallest size of window's width and height SizeWindow(20,20); # attempt to size to 20,20 newWind := FindWindow(pSpecifier); wWidth := newWind.b[3] - newWind.b[1]; wHeight := newWind.b[4] - newWind.b[2]; # assign various sides of screens to easier and shorter variables l1 := s1.r[1]; r1 := s1.r[3]; t1 := s1.r[2]; b1 := s1.r[4]; l2 := s2.r[1]; r2 := s2.r[3]; t2 := s2.r[2]; b2 := s2.r[4]; # determine if screen2 is to left or right of main screen if (r2 = l1) begin # screen 2 is left of screen 1 Dx := l1 - wWidth; # put on right edge of window on left edge of screen 2 # calculate top y value of window if (t2 > t1) begin # mid or low left - put at b1 level of screen 2 if ((b1 - wHeight) < (t2+wHeight)) begin # can't be done LogStr("Screen positions do not allow for sizing across 2 monitors"); return(ResetWindow(wind)); end; Dy := t2; end; else # high-left Dy := b2 - wHeight; Sy := b1-Dy; Sx := wWidth + (r1-l1); end; else if (l2 = r1) begin # screen 2 is right of screen 1 Dx := l2 - wWidth; # put at right of screen 1 if (t2 > t1) # mid or low right Dy := t2 - wHeight; else begin # high right if ((b2 - wHeight) < (t1+wHeight)) begin # can't be done LogStr("Screen positions do not allow for sizing across 2 monitors"); return(ResetWindow(wind)); end; Dy := t1 + pDragXY[2]; end; Sy := b2-Dy; Sx := wWidth + (r2-l2); end; # must be above or below main screen else begin if (l1 > l2) Dx := l2; else Dx := l1; if (t1 < t2) begin # screen below main screen Dy := t2 - wHeight; Sy := b2-t2+wHeight; Sx := r2 - Dx; end; else begin # screen above main screen Dy := t1 - wHeight; Sy := (b1-t1) + wHeight; Sx := r1 - Dx; end; end; DragWindow(Dx,Dy,pSpecifier); LogStr("Sizing window across screen borders..."); SizeWindow(Sx-1,Sy); returnVal := 1; end; else if not (s2) failStr := "Note: Cannot size across screens because the target doesn't have two monitors"; else failStr := "Something not here - couldn't resize across screens"; if not(returnVal) TCSReturn := -1; # Feature not available else TCSReturn := 1; TCSEnd({ 2, global kTCSetUIWindowSize }, TCSReturn,failStr); if(failStr) LogStr(failStr); return(returnVal); end; # SizeAcrossScreens() ######################################################################### # AdjustRectToScreen(pTheRect) #======================================================================== # Author: NJV # Description: This routine checks a rectangle to see if it is within # the screen, if any part of it is not, it will be # clipped so as to fit the screen. This is done by # comparing the coordinates of the rectangle with that of # the screen. # Parameters: pTheRect - holds the coordinates of the rectangle. # Returns: pTheRect - the coordinates of the clipped rectangle. # (if it was not completely within the screen) # or the coordinates of the original rectangle # (if it lies totally within the screen) # Examples: AdjustRectToScreen(Window.r). # Assumptions: All windows are no larger than the screen. #======================================================================== # History: # ML 11/22/94 Added error handling support ######################################################################### TASK AdjustRectToScreen(pTheRect) begin screenList := _collect ([screen]!,1); screenCount := card screenList; if (screenCount = 1) begin # only one screen screenRect := screenList[1].r; Top := pTheRect[2]; # 'Top' cannot go beyond the title bar if (pTheRect[1] <= screenRect[1]) # compare left,top,right and bottom Left := screenRect[1]; # coordinates with screen coordinates else Left := pTheRect[1]; if (pTheRect[3] >= screenRect[3]) Right := screenRect[3]; else Right := pTheRect[3]; if (pTheRect[4] >= screenRect[4]) Bottom := screenRect[4]; else Bottom := pTheRect[4]; pTheRect := {Left,Top,Right,Bottom}; return(pTheRect); end; end; # AdjustRectToScreen() ######################################################################### # CoverCompletely(pFirstWindow,pSecondWindow) #======================================================================== # Author: SMQ # Description: This routine determines whether or not one window # completely covers another. This is done by comparing # the coordinates of both windows. # Parameters: pFirstWindow - specifies the first window. # pSecondWindow - specifies the second window. # Returns: 1 - second window is completely covered by the first. # 0 - second window is partially or totally Uncovered. # Examples: CoverCompletely(window1,window2). # Assumptions: None #======================================================================== # History: # JC 2/6/96 Changed all window .r (Rect) traits to .b (bound) traits. ######################################################################### TASK CoverCompletely (pFirstWindow, pSecondWindow) begin returnVal := 0 ; firstWindow := FindWindow(pFirstWindow); secondWindow := FindWindow(pSecondWindow); firstOrd := firstWindow.o; firstRect := firstWindow.b; secondOrd := secondWindow.o; secondRect := secondWindow.b; if (firstOrd < secondOrd) begin # could be covered - let's check # first, adjust the rectangles - if required Rect2 := AdjustRectToScreen(secondRect); Rect1 := AdjustRectToScreen(firstRect); returnVal := RectInRect(Rect2,Rect1); end; return(returnVal); end; # CoverCompletely() ######################################################################### # ResetWindow(pTheWindow) #======================================================================== # Author: NJV # Description: Resets the first window with a grow and zoom box to # the size and position of the input parameter wind # window descriptor. # Parameters: pTheWindow - window descriptor of original window. # Returns: 0 - error # 1 - no error # Examples: ResetWindow(pTheWindow). # Assumptions: None #======================================================================== # History: # KTA 9/21/94 Fixed trying to reset scrollbars when no thumbnail (0,0) # KTA 1/10/95 Fixed problem - weren't accounting for the e trait for scroll bars. ######################################################################### TASK ResetWindow(pTheWindow) begin global gOrigScrollBars; returnVal := 0; theWind := SelectWindow([window g:true z:true]!); if (theWind) begin windOrd := theWind.o; theTitle := theWind.t; windRect := theWind.r; theDesc := [window t:theTitle o:windOrd]!;# Partial window descriptor contains TITLE and ORD LogStr("==== Restoring window titled ∂"{theTitle}∂" to original size/location"); SizeWindow(20,20,theDesc); DragWindow(pTheWindow.r[1],pTheWindow.r[2],theDesc); SizeWindow(pTheWindow.r[3]-pTheWindow.r[1],pTheWindow.r[4]-pTheWindow.r[2],theDesc); if ((not isUndefined(gOrigScrollBars)) and (global gOrigScrollBars)) begin vert := gOrigScrollBars[1]; Horz := gOrigScrollBars[2]; if (vert) ScrollWindow('V',vert[1],vert[2]); if (horz) ScrollWindow('H',horz[1],horz[2]); end; LogStr("==== Done restoring window titled ∂"{theTitle}∂""); returnVal := 1; end; else Logstr("!@#$% Couldn't select the window"); return(returnVal); end; # ResetWindow() ######################################################################## # SelectWindow(pSpecifier) #======================================================================= # Author: NJV # Description: This routine will select a window specified by # <pSpecifier>. # Parameters: pSpecifier - holds the title or ordinality or window descriptor # of window to select. # Returns: {theDesc} - Updated window descriptor - Selected window OK # 0 - Couldn't find window to select #======================================================================= # History: # KTA 7/19/93 Updated theDesc so descriptor is not embedded in a list. # ML 11/22/94 Added error handling support # JC 2/6/96 Changed all window .r (Rect) traits to .b (bound) traits. ######################################################################## TASK SelectWindow(pSpecifier := 0) begin returnVal := 0; # Init error condition theWind := FindWindow(pSpecifier); if (theWind) begin windOrd := theWind.o; title := theWind.t; boundRect := theWind.b; if(windOrd <> 1) begin UnCoverWindow(pSpecifier); _select ([window o:windOrd t:title]!,1); Logstr("Selected window of ordinality {windOrd} (titled '{title}')"); theDesc := [window t:title b:boundRect]; # Call FindWindow with title and bound rect returnVal := FindWindow(theDesc); # return the updated window descriptor end; else # The specified window is already o:1 returnVal := theWind; end; else Logstr("!@#$% Couldn't select the window"); return(returnVal); end; # SelectWindow() ######################################################################## # UnCoverWindow(pSpecifier, pFrontWindow) #======================================================================= # Author: KTA # Description: This routine will move a window out of the way if it covers # our desired window. # Parameters: pSpecifier - holds the title or ordinality of window that is desired. # pFrontWindow - window that is in front of the desired one. # Returns: Nothing #======================================================================= # History: # KTA 7/20/93 Updated window descriptor so it is not contained with in a list. # KTA 11/8/93 Updated so it is possible to pass in pFrontWindow which # is a window specifier (integer, string, or descriptor) # ML 11/22/94 Added error handling support # JC 2/6/96 Changed all window .r (Rect) traits to .b (bound) traits. ######################################################################## TASK UnCoverWindow(pSpecifier, pFrontWindow := 1) begin returnVal := 0; desiredWindow := FindWindow(pSpecifier); windOrd := desiredWindow.o; theTitle := desiredWindow.t; boundRect := desiredWindow.b; theDesc := [window t:theTitle o:windOrd]; if (windOrd <> 1) # Desired window is not the frontmost window begin # target window not frontmost try match [screen r:?theScreenRect m:true]!; catch theError ExceptionDispatcher(theError); # See if there is another window in front of it if not(pFrontWindow) pFrontWindow := [window g:true z:true]; frontwindow := FindWindow(pFrontWindow); newOrd := frontwindow.o; FboundRect := frontwindow.b; Front := frontwindow.t; frontDesc := [window o:newOrd t:Front]; if (newOrd < windOrd) begin # see if target window is covered up - if so, uncover coverup := CoverCompletely(frontDesc,theDesc); if (coverup) begin # move front window aside to show target window if (boundRect[1] <= 0) DragWindow(20,FboundRect[2],frontDesc,1); else if (boundRect[3] >= theScreenRect[3]) DragWindow(-20,FboundRect[2],frontDesc,1); else DragWindow(boundRect[1]+20,FboundRect[2],frontDesc,1); end; end; end; end; ######################################################################### # DragWindow(pHorizontalPixels, pVerticalPixels,pSpecifier,pAbsolutely) #======================================================================== # Author: KTA # Description: This routine will drag the specified window. # <pHorizontalPixels> pixels horizontally (negative drags left) # and <pVerticalPixels> pixels vertically (negative drags up) # Parameters: pHorizontalPixels - Horizontal pixel offset to drag the window # pVerticalPixels - Vertical pixel offset to drag the window # pSpecifier - Window specifier # pAbsolutely - 1 if absolute drag # 0 if relative drag # Returns: 1 - Dragged window OK # 0 - Couldn't find window to drag #======================================================================== # History: # KTA 8/24/93 TCS stack parity check # KTA 9/21/93 Added a TCSStr to the TCSEnd call, which descibes the action # KTA 3/15/94 Added outputting ordinality. # ML 11/22/94 Added error handling support # KTA 12/21/94 Removed errant {str1} ######################################################################### TASK DragWindow(pHorizontalPixels := "Random", pVerticalPixels := "Random", pSpecifier := 0,pAbsolutely := 1) begin if (global gScreenInset) inset := gScreenInset; else inset := { 0,20,10,10}; noErrorFlag := 0; # Init error condition if (pHorizontalPixels = "Random") or (pHorizontalPixels = "RandomReturn") begin # user wants random coordinates if (pHorizontalPixels = "RandomReturn") RandReturn := 1; xyRandom := getXYRandom(inset); pHorizontalPixels := xyRandom[1]; pVerticalPixels := xyRandom[2]; end; theWind := FindWindow(pSpecifier); if (theWind) begin windOrd := theWind.o; title := theWind.t; if (RandReturn) # Save original coordinates begin origH := theWind.r[1]; origV := theWind.r[2]; end; TCSStart({ 1, global kTCSetUIWindowDrag },"DragWindow"); # Start TCS if (pAbsolutely) begin _drag ([window o:windOrd t:title]!, 'a',{pHorizontalPixels,pVerticalPixels},1); #To drag the window str := "Dragged window titled '{title}' (ordinality '{windOrd}') to absolute location ∂({pHorizontalPixels},{pVerticalPixels}∂)"; noErrorFlag := 1; end; else begin _drag ([window o:windOrd t:title]!, 'r', {pHorizontalPixels,pVerticalPixels},1); #To drag the window str := "Dragged window titled '{title}' (ordinality '{windOrd}') {pHorizontalPixels} pixels horizontally and {pVerticalPixels} pixels vertically"; noErrorFlag := 1; end; TCSEnd({ 1, global kTCSetUIWindowDrag }, noErrorFlag,,,str); LogStr(str); if (RandReturn) #Move back to original location begin TCSStart({ 3, global kTCSetUIWindowDrag },"DragReturn"); # Start TCS _drag ([window o:windOrd t:title]!, 'a', {origH,origV},1); #To drag the window str := "Dragged window titled '{title}' (ordinality '{windOrd}') back to it's original location at ∂({Origh}, {Origv}∂)"; TCSEnd({ 3, global kTCSetUIWindowDrag }, noErrorFlag,,,str); LogStr(str); end; end; return(noErrorFlag); end; # DragWindow() ######################################################################### # SizeWindow(pPixelsWide,pPixelsHigh,pSpecifier,pAbsolutely) #======================================================================== # Author: KTA # Description: This routine will match and resize the specified window. # If only the <pPixelsWide> and <pPixelsHigh> parameters are # passed, the default behavior will size the first window # containing a grow and zoom box pAbsolutely. If no parameters # are passed, then the default behavior will generate random # coordinates on the main screen and resize the window # to an absolute size. If the user passes in the string # "random" for <pPixelsWide> and <pPixelsHigh> and passes 0 for # the pAbsolutely parameter (for a resize relative to current size), # then checks are performed to assure that new size will # not go off of the screen. If it does, the values will # be adjusted so that the largest the window can be sized # is to the border of the screen. # Parameters: pPixelsWide - the width to resize the window # pPixelsHigh - the height to resize the window # pSpecifier - title or ordinality of window to be sized # pAbsolutely - 1 if resize window absolute # 0 if resize window relative # Returns: 1 - Resized window OK # 0 - Couldn't resize window # Examples: SizeWindow(200,400); #======================================================================== # History: # KTA 8/24/93 TCS stack parity check # KTA 12/16/93 Insure that pixels wide is not smaller than 20. # KTA 3/15/94 Added outputting of ordinality # ML 11/22/94 Added error handling support # JC 2/6/96 Changed all window .r (Rect) traits to .b (bound) traits. ######################################################################### TASK SizeWindow(pPixelsWide:="random", pPixelsHigh:="random", pSpecifier := 0, pAbsolutely := 1) begin if (global gScreenInset) inset := gScreenInset; else inset := { 20,20,0,0}; noErrorFlag := 0; TCSReturn := 0; theWind := FindWindow(pSpecifier); pSpecifier := theWind.o; title := theWind.t; sizeBox := theWind.g; theWindBoundRect := theWind.b; if (theWind) begin TCSStart({ 1, global kTCSetUIWindowSize },"SizeWindow"); # Start TCS if (sizeBox) begin randomFlag := 0; if (pPixelsWide = "random") # user wants to size window randomly begin if (inset[1] < 20 ) # Insure that we do not try to size the window to smaller than 20 pixels or inset := replace(20,1,inset); # VU will generate an "Out of bounds error" xyRandom := getXYRandom(inset); pPixelsWide := xyRandom[1]; pPixelsHigh := xyRandom[2]; randomFlag := 1; if (not pAbsolutely) # relative - include possible negative values begin negative := random(0,1); if (negative = 1) begin pPixelsWide := 0 - pPixelsWide; pPixelsHigh:= 0 - pPixelsHigh; end; end; end; # pSpecifier = ordinality of window to size # title = title of window to size if (randomFlag) # make sure if random numbers were generated that new window size is on screen begin try match [screen r:?theScrnRect]!; catch theError ExceptionDispatcher(theError); if (pAbsolutely) # get Top-Left corner coord of window begin if ((theWindBoundRect[1] + pPixelsWide) > theScrnRect[3]) # pPixelsWide value off of screen - adjust it pPixelsWide := theScrnRect[3] - theWindBoundRect[1]; if ((theWindBoundRect[2] + pPixelsHigh) > theScrnRect[4]) # pPixelsHigh value off of screen - adjust it pPixelsHigh := theScrnRect[4] - theWindBoundRect[2]; end; else # size window relative - get Bottom-Right coord of window begin if (not negative) begin if ((theWindBoundRect[3] + pPixelsWide) > theScrnRect[3]) # pPixelsWide value off of screen pPixelsWide := theScrnRect[3] - theWindBoundRect[3]; if ((theWindBoundRect[4] + pPixelsHigh) > theScrnRect[4]) # pPixelsHigh value off of screen pPixelsHigh := theScrnRect[4] - theWindBoundRect[4]; end; ### the 20 in the equations below must be there. This is to assure that ### the window is not sized below 20 horizontally (the size box is 20 pixels, ### and attempts to size smaller than that will cause VU to display an ### "Out of bounds" error. else begin # negative value - must check against upper-left corner of screen if ((theWindBoundRect[3] + pPixelsWide - 20) < theScrnRect[1]) # pPixelsWide value off of screen pPixelsWide := 20 - theWindBoundRect[3] - theScrnRect[1]; if ((theWindBoundRect[4] + pPixelsHigh - 20) < theScrnRect[2]) # pPixelsHigh value off of screen pPixelsHigh := 20 - theWindBoundRect[4] - theScrnRect[2]; end; end; end; if (pAbsolutely) begin try size [window t:title o:pSpecifier g:true] W:pPixelsWide H:pPixelsHigh; #To size the window catch sizeError ExceptionDispatcher(sizeError); if not (sizeError) begin try match [window t:title o:pSpecifier g:true b:?theWindBoundRect]!; catch theError ExceptionDispatcher(theError); pPixelsWide := theWindBoundRect[3] - theWindBoundRect[1]; pPixelsHigh := theWindBoundRect[4] - theWindBoundRect[2]; str := "Resized window '{title}' (ordinality '{pSpecifier}') absolute {pPixelsWide} pixels wide and {pPixelsHigh} pixels high"; noErrorFlag := 1; end; end; else begin if (randomFlag) # include negative offsets for random size begin try match [window t:title o:pSpecifier g:true b:?theOrigWindRect]!; catch theError ExceptionDispatcher(theError); try size [window t:title o:pSpecifier g:true ] r:{ pPixelsWide, pPixelsHigh }; #To size the window catch sizeError ExceptionDispatcher(sizeError); if not (sizeError) begin try match [window t:title o:pSpecifier g:true b:?theWindBoundRect]!; catch theError ExceptionDispatcher(theError); pPixelsWide := theWindBoundRect[3] - theOrigWindRect[3]; pPixelsHigh := theWindBoundRect[4] - theOrigWindRect[4]; str := "Resized window '{title}' (ordinality '{pSpecifier}') relative {pPixelsWide} pixels wide and {pPixelsHigh} pixels high"; noErrorFlag := 1; end; end; else begin try size [window t:title o:pSpecifier g:true] r:{ pPixelsWide, pPixelsHigh }; #To size the window catch sizeError ExceptionDispatcher(sizeError); if not (sizeError) begin try match [window t:title o:pSpecifier g:true b:?theWindBoundRect]!; catch theError ExceptionDispatcher(theError); pPixelsWide := theWindBoundRect[3] - pPixelsWide; pPixelsHigh := theWindBoundRect[4] - pPixelsHigh; str := "Resized window '{title}' (ordinality '{pSpecifier}') relative {pPixelsWide} pixels wide and {pPixelsHigh} pixels high"; noErrorFlag := 1; end; end; end; end; # Is sizeBox else # No sizeBox sizeError := 1; ##### Error handling for Size window ##### if (sizeError) # if there was no error, failStr = "" begin if(sizeError = -1106) begin str := "Couldn't size window (ordinality '{pSpecifier}'), SizeBox was off screen (ScriptError = -1106)"; TCSReturn := -1; end; else if(sizeError = -1130) str := "Couldn't size window (ordinality '{pSpecifier}'), window not active (ScriptError = -1130)"; else if(sizeError = 1) str := "No size box found in window titled '{title}' (ordinality '{pSpecifier}'),"; else str := "Couldn't size window (ordinality '{pSpecifier}'), an error occurred while attempting to size to coords ({pPixelsWide},{pPixelsHigh}) - (ScriptError = {sizeError})"; TCSInfoStr := ""; FailStr := Str; end; else # No sizeError (sized correctly) begin TCSReturn := noErrorFlag; FailStr := ""; TCSInfoStr := "Sized window titled '{title}' (ordinality '{pSpecifier}') to coords ({pPixelsWide},{pPixelsHigh})"; end; TCSEnd({ 1, global kTCSetUIWindowSize }, TCSReturn, FailStr,,TCSInfoStr); LogStr(str); end; return(noErrorFlag); end; # SizeWindow() ######################################################################### # ZoomWindow(pSpecifier) #======================================================================== # Author: KTA # Description: Selects the zoom box on the specified window. If no # parameters are passed, then the default behavior will # zoom the first window with a zoom box. # Parameters: pSpecifier - window specifier # Returns: 0 - Couldn't zoom the window # 1 - Zoomed the window OK #======================================================================== # History: # KTA 8/24/93 TCS stack parity check # KTA 3/15/94 Added outputting of ordinality # ML 11/22/94 Added error handling support # JC 2/7/96 Removed "theRect := theWind.r; # njv - added 6/25/91 # theHitPoint := {theRect[3]-20,theRect[2]}; # hit point for zoom box # hitPointOffScreen := true;" they were not being used. # ######################################################################### TASK ZoomWindow(pSpecifier:= 0) begin noErrorFlag := 0; # Init error condition TCSReturn := 0; # Init TCS Return value FailStr := ""; # Init fail string TCSInfoStr := ""; theWind := FindWindow(pSpecifier); if theWind begin windOrd := theWind.o; title := theWind.t; zoomBox := theWind.z; TCSStart({ 1, global kTCSetUIWindowMiscOp }, "Zoom"); # TCS Start if (zoomBox) begin try zoom [window o:windOrd t:title]!; #To zoom the window catch zoomError ExceptionDispatcher(zoomError); if (not zoomError) begin str := "Zoomed window titled '{title}' (ordinality '{windOrd}')"; noErrorFlag := 1; # Success! end; end; else # No ZoomBox zoomError := 1; ##### Error handling for Zoom window ##### if (zoomError) # if there was no error, failStr = "" begin if(zoomError = -1106) begin str := "Couldn't zoom window titled '{title}' (ordinality '{windOrd}'), ZoomBox was off screen (ScriptError = -1106)"; TCSReturn := -1; end; else if(zoomError = -1130) str := "Couldn't zoom window titled '{title}' (ordinality '{windOrd}'), window not active (ScriptError = -1130)"; else if(zoomError = 1) str := "No zoom box found in window titled '{title}' (ordinality '{windOrd}')"; else str := "Couldn't zoom window titled '{title}' (ordinality '{windOrd}'), an error occurred (ScriptError = {sizeError})"; FailStr := Str; end; else # No zoomError (zoomed correctly) begin TCSReturn := noErrorFlag; # Normally this will be a 1 indicating success FailStr := ""; # No FailStr since success TCSInfoStr := Str; end; TCSEnd({ 1, global kTCSetUIWindowMiscOp }, TCSReturn, FailStr,,TCSInfoStr); LogStr(str); end; return(noErrorFlag); end; # ZoomWindow() ######################################################################### # CloseWindow(pHowClose, pOverwrite, pSpecifier,pNewDocName) #======================================================================== # Author: KTA/NJV/DMM # Description: This routine will close the specified window. If no # parameters are passed to this routine, the default behavior # will select the close box of the first window with a close box. # Parameters: pHowClose - 0 - tries all three ways noted below to close the # window (if needed) # 1 - tries to close window by selecting "Close" menu # item # 2 - tries to close window by typing "Close" menu # item's key equivalent # 3 - tries to close window by selecting window's # close box # pOverwrite - 0 - will select "No" from a save-changes dialog # if one appears when closing window # 1 - will select "Yes" to save changes # pSpecifier - window specifier # pNewDocName - string holding new document name - if pOverwrite # parameter is 1, then pNewDocName will be used for # naming the file. # Returns: 1 - Closed window OK # 0 - Couldn't find window to close #======================================================================== # History: # KTA 7/19/93 Removed theWind descriptor from being embedded in a list # KTA 7/23/93 Added a wait(2) prior to 'Save Document?? check also made # call to IsStandardFile instead of matching 'DeskTop' button. # KTA 8/24/93 TCS stack parity check # KTA 12/01/93 Enhanced check if window was closed to also check by the # rect of the window. (bug 1120098) # ML 11/22/94 Added error handling support # JC 2/6/96 Changed all window .r (Rect) traits to .b (bound) traits. ########################################################################### TASK CloseWindow(pHowClose := 3,pOverWrite := 1,pSpecifier := 0,pNewDocName :="") begin noErrorFlag := 0; theWind := FindWindow(pSpecifier); # Find the specified window if (theWind) begin # IF - we found the window ord := theWind.o; # make assignments theTitle := theWind.t; theGrow := theWind.g; theZoom := theWind.z; theBoundRect := theWind.b; if (ord <> 1) begin SelectWindow(ord); # Select the window if it's not the frontmost theWind := FindWindow([window t:theTitle g:theGrow z:theZoom]!); ord := theWind.o; # Reassign Ord because selection may have changed ordinality end; if (not pHowClose) # Try all methods until one works pHowClose := {1,2,3}; else pHowClose := {pHowClose}; # Just use the specified method numItems := Card(pHowClose); for i := 1 to numItems # Execute once if way to close is specified begin # otherwise three times attempting all methods closeMethod := pHowClose[i]; if (closeMethod = 1) begin # Close with menu item TCSNum := 2; TCSStart({ TCSNum, global kTCSetUIWindowClose }, "CloseFromFileMenu"); if(SelectMenuItem("Close","File")) noErrorFlag := 1; # Success end; else if (closeMethod = 2) begin # Close with key equivelant closeKey := _match ([menuItem t:"Close"]); TCSNum := 2; TCSStart({ TCSNum, global kTCSetUIWindowClose }, "CloseFromKeyEq"); if (closeKey.k) begin KeyEq(closeKey.k); noErrorFlag := 1; # Success end; end; else if (closeMethod = 3) begin # Close with close box TCSNum := 1; TCSStart({ TCSNum, global kTCSetUIWindowClose }, "CloseBox"); if (theWind.c) begin _close ([window o:ord t:theTitle c:true]!,1); LogStr("Selected the close box on window titled '{theTitle}' (ordinality '{ord}')"); noErrorFlag := 1; # Success end; else LogStr("Couldn't find the close box on window titled '{theTitle}' (ordinality '{ord}')"); end; if (noErrorFlag) # IF - we had a success i := numItems; # break because window should be closed end; if (noErrorFlag) # IF - we had a success begin wait(2); # Wait to allow dialog to appear if(checkYesNo(pOverWrite)) # Check if a 'Save Document??' dialog appeared begin if(pOverWrite) # if the dialog appeared and we want to save begin if (IsStandardFile()) # check for Standard File begin SaveAs(pNewDocName,true); theTitle := Global gLastSavedFile; end; end; end; end; if(_matchBoolean ([window t:theTitle b:theBoundRect]!)) # Is the window we just closed still open begin LogStr("!@#$% Sorry, the window - {theTitle} is still open"); noErrorFlag := 0; end; TCSEnd({ TCSNum, global kTCSetUIWindowClose }, noErrorFlag); # End TCS end; return(noErrorFlag); # Return Result end; # CloseWindow() ######################################################################## # ScrollWindow(pWhichScrollBar,pDesirePosition,pMaxPosition) #======================================================================= # Author: KTA/NJV # Description: This routine will scroll the specified scrollbar on # the active window. # Parameters: pWhichScrollBar = 'H' - for horizontal scrollbar # = 'V' - for vertical scrollbar # <pDesirePosition><pMaxPosition> = the fraction pDesirePosition/pMaxPosition # Returns: 0 - Couldn't scroll the scroll bar # 1 - Scrolled the scroll bar # Examples: ScrollWindow('H',1,2) will scroll the horizontal bar 1/2 # Assumptions: That the scrollbars are present. This routine collects # only the first two scroll bars, which are assumed to be # the horizontal and vertical scroll bars. # This routine is not 100% reliable. #======================================================================= # History: # KTA 8/24/93 TCS stack parity check # KTA 9/10/93 Better check to see if scroll bars are on screen # ML 11/22/94 Added error handling support ######################################################################### TASK ScrollWindow(pWhichScrollBar,pDesirePosition:=-1,pMaxPosition:=-1) begin returnVal := 0; failStr := ''; theScrollBars := GetVHScrollBars(); theScreen := _match([screen]); if (theScrollBars) begin vertical := theScrollBars[1]; verticalDiff := vertical.s; horizontal := theScrollBars[2]; horizontalDiff := horizontal.s; if (pWhichScrollBar = 'V') or (pWhichScrollBar = 'v') begin if (pDesirePosition=-1) or (pMaxPosition=-1) # generate random value begin pDesirePosition := random(0,verticalDiff[2]); pMaxPosition := verticalDiff[2]; end; TCSNum := 1; TCSStart({ TCSNum, global kTCSetUIWindowScroll },"VerticalScroll"); # Start TCS if not(vertical.s = {0,0}) #Test to see if Scrollbars are enabled begin if (vertical.e) #Test to see if Scrollbars are enabled begin if(vertical.r[1] < theScreen.r[3]) begin try scroll vertical a:{pDesirePosition,pMaxPosition}; catch scrollError ExceptionDispatcher(scrollError); if not (scrollError) begin LogStr("Scrolled the vertical scroll bar Absolute ({pDesirePosition}, {pMaxPosition})"); returnVal := 1; end; end; else begin LogStr("!@#$% The vertical scroll bar is off the screen"); failStr := "!@#$% The vertical scroll bar is off the screen"; end; end; else begin LogStr("!@#$% The vertical scroll bar was not enabled to scroll"); failStr := "!@#$% The vertical scroll bar was not enabled to scroll"; end; end; else begin LogStr("!@#$% The vertical scroll bar was not enabled to scroll - no thumbnail"); failStr := "!@#$% The vertical scroll bar was not enabled to scroll - no thumbnail"; end; end; else begin if (pDesirePosition=-1) or (pMaxPosition=-1) # generate random value begin pDesirePosition := random(0,horizontalDiff[2]); pMaxPosition := horizontalDiff[2]; end; TCSNum := 2; TCSStart({ TCSNum, global kTCSetUIWindowScroll },"HorizontalScroll"); # Start TCS if not(horizontal.s = {0,0}) #Test to see if Scrollbars are enabled begin if (horizontal.e) #Test to see if Scrollbars are enabled begin if(horizontal.r[2] < theScreen.r[4]) begin try scroll horizontal a:{pDesirePosition,pMaxPosition}; catch scrollError ExceptionDispatcher(scrollError); if not (scrollError) begin LogStr("Scrolled the horizontal scroll bar absolute ({pDesirePosition}, {pMaxPosition})"); returnVal := 1; end; end; else begin LogStr("!@#$% The horizontal scroll bar is off the screen"); failStr := "!@#$% The horizontal scroll bar is off the screen"; end; end; else begin LogStr("!@#$% The horizontal scroll bar was not enabled to scroll"); failStr := "!@#$% The horizontal scroll bar was not enabled to scroll"; end; end; else begin LogStr("!@#$% The horizontal scroll bar was not enabled to scroll - no thumbnail"); failStr := "!@#$% The horizontal scroll bar was not enabled to scroll - no thumbnail"; end; end; if(scrollError) begin if (scrollError = -1150) failStr := failstr + "Couldn't scroll because the scroll bar is off the screen"; end; if not(returnVal) TCSReturn := -1; # Feature not available else TCSReturn := 1; TCSEnd({ TCSNum, global kTCSetUIWindowScroll }, TCSReturn,failStr); end; return(returnVal); end; # ScrollWindow() ######################################################################## # GetVHScrollBars() #======================================================================= # Author: NJV # Description: This routine will return the vertical and horizontal # scroll bars. # Parameters: pSpecifier - Window descriptor # Returns: 0 - Couldn't find scroll bars # {vertical,horizontal} - list of vertical and horizontal # scroll bars # Examples: scrollBars := GetVHScrollBars(); # Assumptions: Top of vertical scroll bar is at a lower vertical value # that the horizontal (i.e. the top of vertical rect is smaller # than the top of the horizontal scroll bar's rect). #======================================================================= # History: # ML 11/22/94 Added error handling support # KTA 1/31/95 Added parameter pSpecifier ######################################################################### TASK GetVHScrollBars(pSpecifier := [window c:true g:true]) begin ScrollWindowlist := _collect([scrollbar w:pSpecifier]!); if not (card(ScrollWindowlist)) begin LogStr("!@#$% There were no recognizable scroll bars present"); return(0); end; Rec1 := ScrollWindowlist[1]; Rec2 := ScrollWindowlist[2]; Rec1R := Rec1.r[1]; Rec2R := Rec2.r[1]; if (Rec1R < Rec2R) begin #To determine which scroll bar is Vertical/Horizontal horizontal := Rec1; vertical := Rec2; end; else begin horizontal := Rec2; vertical := Rec1; end; return({vertical,horizontal}); end; ######################################################################### # CloseAllWindows() #======================================================================= # Author: ML # Description: Closes all windows having a close box. # Parameters: None # Returns: Nothing # Assuptions: Windows have close boxes. #======================================================================= # History: # KTA 2/10/95 Call findWindow with booleanFlag set ######################################################################## TASK CloseAllWindows() begin KeepGoingFlag := 1; While (KeepGoingFlag) begin if (FindWindow([window c:true]!, true)) KeepGoingFlag:= CloseWindow(,,[window c:true]!); else KeepGoingFlag:=0; end; end; ######################################################################### # FindWindow(pSpecifier) #======================================================================== # Author: DM # Description: FindWindow will return the descriptor of the window # specified by the parameter pSpecifier. # Parameters: pSpecifier - if string, then it holds title of window # if integer, then it holds ordinality of window # if rect, create a fake window specfier with the # rect as the wind.r # if window descriptor will match window meeting # the specified traits e.g. [window t:'Mywind' o:2] # Pass 0 to get the first document window # pBooleanFlag - IF set will return true or false indicating the presence of # window specified by <pSpecifier>. Note: No window # descriptor will be returned. # Returns: 0 - Couldn't find the window # descriptor - Window descriptor that meets the specified match # for <pSpecifier> # Example: FindWindow(1); #======================================================================== # History: # KTA 7/19/93 Added support for pSpecifier type 'descriptor' removed embedding into list. # ML 11/22/94 Added error handling support # KTA 2/10/95 Added pBooleanFlag # JC 2/6/96 Changed "theDesc := [window r:pSpecifier t:"RECTANGLE" o:0];" to "theDesc := [window b:pSpecifier t:"RECTANGLE" o:0];". ######################################################################### TASK FindWindow(pSpecifier := "None", pBooleanFlag := false) begin WindType := TypeOf(pSpecifier); if (WindType = 'descriptor') begin if(pBooleanFlag) theDesc := _matchBoolean (pSpecifier); else theDesc := _match (pSpecifier!,1); end; else if (WindType = 'string') or (WindType = 'regularExpression') begin if(pBooleanFlag) theDesc := _matchBoolean ([window t:pSpecifier]); else begin theDesc := _match ([window t:pSpecifier]!,1); if (not theDesc) LogStr("!@#$% Couldn't match a window of title {pSpecifier}"); end; end; else if(WindType = 'integer') begin if(pSpecifier > 0) begin if(pBooleanFlag) theDesc := _matchBoolean ([window o:pSpecifier]); else begin theDesc := _match ([window o:pSpecifier]!,1); if (not theDesc) LogStr("!@#$% Couldn't match a window of ordinality {pSpecifier} with a grow box"); end; end; else begin if(pSpecifier = 0) begin if(pBooleanFlag) theDesc := _matchBoolean ([window c:true g:true]); else begin theDesc := _match ([window c:true g:true]!,1); if (not theDesc) LogStr("!@#$% Couldn't match a window with a close and grow box"); end; end; else begin if (pSpecifier < 0) begin scrList := _collect ([screen]!,1); theDesc := scrList[-pSpecifier]; if (not theDesc) begin scrOrd:=-pSpecifier; LogStr("!@#$% Couldn't match a screen with ordinality {scrOrd}"); theDesc := []; end; end; end; end; end; else if(WindType = 'list') begin if((TypeOf(pSpecifier[1]) = 'integer')) begin theDesc := [window b:pSpecifier t:"RECTANGLE" o:0]; LogStr("Faked out FindWindow with a rectangle!!"); end; else # the old way was e.g.FindWindow({[window t:'Untitled']}); println " +++++++++ Error: Its an old FindWindow() Descriptor"; end; return (theDesc); end; # FindWindow() ######################################################################## # GetRandomPointsRelativeToWindow(pInset, pSpecifier, pNumPts) #======================================================================= # Author: KTA # Description: Determines what the rectangle is for the window specified # as Specifier and returns a random X and Y coordinate which # will be inside the window if moving relative to the top # left corner of the screen or window. # Parameters: pInset - ltrb inset from screen or window # pSpecifier # Integer # > 0 - Ordinality window to find coords in # = O coords in window with s:doc g:true and c:true # < 0 coords in specified screen. Screen numbers # are negative of pSpecifier. # String # title of window to find coords in # {List} # any partial or complete window descriptor # Returns: myPoints - List of random X and Y. eg. { x, y } #======================================================================== # History: # JC 2/6/96 Changed all window .r (Rect) traits to .b (bound) traits. # JC 2/6/96 Changed "pInset := { 0,20,20,20}" to "pInset := { 0,20,20,20}". ######################################################################## TASK GetRandomPointsRelativeToWindow(pInset := { 0,0,20,20}, pSpecifier := 0, pNumPts := 1) begin theDesc := FindWindow(pSpecifier); if(theDesc) begin windowBoundRect := theDesc.b; myPoints := GetXYRandom(pInset, windowBoundRect, pNumPts); end; return(myPoints); end; #======================================================================= # Dialog related tasks: #======================================================================= ######################################################################### # SelectButton(pButton) #======================================================================== # Author: KTA # Description: This routine will select the button named <pButtonName> # Parameters: pButton - string - holding name of button to select # integer - ordinality of Button # Returns: 0 - Couldn't select button # pButtonName - Selected button OK #======================================================================== # History: # KTA 7/6/93 Performance support: Call (gBeginTimer); # KTA 9/13/93 Added support for selecting Buttons for by ordinality # KTA 9/21/93 Changed gBeginTimer to gPreSelectButtonHook # KTA 9/21/93 Changed gBeginTimer to gPreSelectButtonHook # KTA 11/12/93 Changed select[button] to move over the button then click # for performance - doesn't require additional match. This # is done to reduce the amount of VU overhead required in matching # the button. # KTA 11/16/93 Do logging prior to actually selecting button for performance. # KTA 12/01/93 Added support for button descriptors. # KTA 3/15/94 Added outputting ordinality. # ML 11/22/94 Added error handling support ######################################################################### TASK SelectButton(pButton) begin returnVal := 0; ParameterType := typeOf(pButton); if (ParameterType = 'string') IsButton := _match ([button t:pButton]!,1); else if (ParameterType = 'integer') IsButton := _match ([button o:pButton]!,1); else if (ParameterType = 'descriptor') begin if(DescType(pButton) = 'button') IsButton := _match (pButton!,1); else logStr("!@#$% The descriptor '{pButton}' is not a valid button descriptor"); end; if (IsButton) begin theButtonTitle := IsButton.t; theButtonOrd := IsButton.o; if (IsButton.e) begin LogStr( "Selecting button titled '{theButtonTitle}' (ordinality '{theButtonOrd}')"); _move ('a', {((IsButton.r[1]+IsButton.r[3])/2),((IsButton.r[2]+IsButton.r[4])/2)}); if (global gPreSelectButtonHook) Call(gPreSelectButtonHook); _click(); #Select [button t:theButtonTitle]!; returnVal := theButtonTitle; end; else LogStr("!@#$% Couldn't select button named '{theButtonTitle}' (ordinality '{theButtonOrd}') because it's not enabled"); end; else LogStr("!@#$% There was no button specified by '{pButton}'"); return(returnVal); end; # SelectButton() ####################################################################### # SelectRadioButton(pRadioButton) #======================================================================== # Author: KTA # Description: This routine will select RadioButton named <pRadioButtonName> # Parameters: pRadioButton - string - name of radio button to select # integer - radio button ordinality # Returns: 0 - Couldn't select radio button # pRadioButtonName - Selected button OK #======================================================================== # History: # KTA 9/13/93 Added support for selecting radioButtons for by ordinality # KTA 3/15/94 Added outputting ordinality # KTA 9/20/94 Select by title and ordinality instead of just ordinality # ML 11/22/94 Added error handling support ######################################################################### TASK SelectRadioButton(pRadioButton) begin returnVal := 0; if (typeOf(pRadioButton) = 'string') IsRadioButton := _match ([RadioButton t:pRadioButton]!,1); else if (typeOf(pRadioButton) = 'integer') IsRadioButton := _match ([RadioButton o:pRadioButton]!,1); if (IsRadioButton) begin theRadioButtonTitle := IsRadioButton.t; theRadioButtonOrd := IsRadioButton.o; if (IsRadioButton.e) begin _Select ([RadioButton t:theRadioButtonTitle o:theRadioButtonOrd]); str := "Selected radio button titled '{theRadioButtonTitle}' (ordinality '{theRadioButtonOrd}')"; returnVal := theRadioButtonTitle; end; else str := "!@#$% Couldn't select radio button named '{theRadioButtonTitle}' (ordinality '{theRadioButtonOrd}') because it's not enabled"; end; else str := "!@#$% There was no radio button specified by '{pRadioButton}'"; LogStr(str); return(returnVal); end; # SelectRadioButton() ######################################################################### # SelectCheckBox(pCheckBox) #======================================================================== # Author: KTA # Description: This routine will select CheckBox named <pCheckBoxName> # Paramters: pCheckBox - string - name of check box to select # integer - ordinality of checkBox # Returns: 0 - Couldn't select check box # pCheckBoxName - Selected check box OK #======================================================================== # History: # KTA 9/13/93 Added support for selecting CheckBox for by ordinality # KTA 3/15/94 Added outputting ordinality # KTA 9/20/94 # ML 11/22/94 Added error handling support ######################################################################### TASK SelectCheckBox(pCheckBox) begin returnVal := 0; if (typeOf(pCheckBox) = 'string') isSelectCheckBox := _match ([CheckBox t:pCheckBox]!,1); else if(typeOf(pCheckBox) = 'integer') isSelectCheckBox := _match ([CheckBox o:pCheckBox]!,1); if (isSelectCheckBox) begin theCheckBoxTitle := isSelectCheckBox.t; theCheckBoxOrd := isSelectCheckBox.o; if (isSelectCheckBox.e) begin _Select ([CheckBox t:theCheckBoxTitle o:theCheckBoxOrd ]); str := "Selected check box titled '{theCheckBoxTitle}' (ordinality '{theCheckBoxOrd}')"; returnVal := theCheckBoxTitle; end; else str := "!@#$% Couldn't select check box named '{theCheckBoxTitle}' (ordinality '{theCheckBoxOrd}') because it's not enabled"; end; else str := "!@#$% There was no check box specified by '{pCheckBox}'"; LogStr(str); return(returnVal); end; # SelectCheckBox() ######################################################################### # CheckYesNo(pFlag) #======================================================================== # Author: SL # Description: Checks for dialog boxes with "Yes" (or "OK") and "No" # buttons. If they are found, clicks one of the buttons # depending on the 'pFlag' parameter. # Parameters: pFlag - TRUE - Selects "Yes" or "OK" button. # FALSE - Selects "No" button. # DocName - Name that docment will be saved with. # Returns: What is returned by SelectButton #======================================================================== # History: # ML 6/9/94 Handle both kinds of apostrophes in "Don't Save" # ML 11/22/94 Added error handling support # ML 2/6/95 use _MatchBoolean instead of _match # ML 11/21/95 add support for internationl # MDF 04/25/96 Fixed bug where selection of 'No' button failed when gNoString # was undefined. ######################################################################### TASK CheckYesNo(pFlag := true) begin global gYesString, gOKString, gSaveString, gNoString, gDontSaveString; if (IsUndefined (gOKString)) okString := "OK"; else okString := gOKString; if (IsUndefined (gYesString)) yesString := "Yes"; else yesString := gYesString; if (IsUndefined (gSaveString)) saveString := "Save"; else saveString := gSaveString; if (IsUndefined (gNoString)) noString := "No"; else noString := gNoString; if ( pFlag ) begin yesBtn := _matchBoolean ([button t:yesString w:[window o:1]]!); okBtn := _matchBoolean ([button t:okString w:[window o:1]]!); saveBtn := _matchBoolean ([button t:saveString w:[window o:1]]!); if (yesBtn) return(SelectButton(yesString)); else if (okbtn) return(SelectButton(okString)); else if (saveBtn) return(SelectButton(saveString)); end; else begin noBtn := _matchBoolean ([button t:noString w:[window o:1]]!); if (noBtn) return(SelectButton(noString)); else begin if (gDontSaveString) IsDontSaveBtn := _matchBoolean ([button t:gDontSaveString w:[window o:1]]!); else IsDontSaveBtn := _matchBoolean ([button t:/Don?t Save/ w:[window o:1]]!); if (IsDontSaveBtn) begin if (gDontSaveString) IsDontSaveBtn := _match ([button t:gDontSaveString w:[window o:1]]!,1); else IsDontSaveBtn := _match ([button t:/Don?t Save/ w:[window o:1]]!,1); DontSaveBtn := IsDontSaveBtn.t; return(SelectButton(DontSaveBtn)); end; end; end; end; # CheckYesNo() ######################################################################## # DialogCheck(pFindStaticText,pCommitButton, pLogIT, pWindowDesc) #======================================================================= # Author: KTA # Description: This routine will to match a dialog of specified by <pWindowDesc>, # with static text - <pFindStaticText>, if found it will select the # Button - {pCommitButton}. If <pFindStaticText> is not defined a # match will be made on any dialog with static text. # Parameters: pFindStaticText - Static text string that you want to match # pCommitButton - Button to select if the static text is found. # pLogIT - If you don't want to log the dialog pass 0 # pWindowDesc - window descriptor of dialog # Returns: <Static Text> - the Static Text String found pFindStaticText # and selected pCommitButton # 0 - Couldn't find pFindStaticText #======================================================================= # History: # KTA 7/6/93 Changed default pWindowDesc so it doesn't include c:False # KTA 11/11/93 Updated so if pFindStaticText = '' it will not need to be a substring # KTA 11/15/93 Moved ! in collect statement so it would actually work # KTA 12/01/93 Added support for button descriptors # ML 11/22/94 Added error handling support # ML 12/13/94 Cleaner error handling when checking for the window # remove extraneous returnval assignment ######################################################################## TASK DialogCheck(pFindStaticText :='', pCommitButton :="", pLogIT := 1, pWindowDesc := [window o:1 c:false]) begin returnVal := 0; if _matchBoolean([staticText w:pWindowDesc]!) begin DialogWin := _collect([staticText w:pWindowDesc]!,1); if (DialogWin) begin NumStaticItems:= card (DialogWin); for i:= 1 to NumStaticItems begin StaticItem:= DialogWin[i]; theStaticText := StaticItem.t; if not( theStaticText = '') begin if((IsSubString(pFindStaticText, theStaticText)) or (pFindStaticText = '')) begin if (pLogIT) LogStr("Found Dialog: '{theStaticText}'"); if (pCommitButton) begin ParameterType := typeOf(pCommitButton); if ((ParameterType = 'string') or (ParameterType = 'descriptor')) SelectButton(pCommitButton); else if (pCommitButton = 1) SpecialKey(returnKey, "Return Key"); else LogStr('!@#$% Method of dismissing Dialog was not valid'); end; returnVal := theStaticText; NumStaticItems:=i; end; end; end; end; # if (DialogWin) end; # if _matchBoolean([staticText w:pWindowDesc]!) return(returnVal); end; # DialogCheck() ######################################################################### # DialogHandler(pSpecifier) #======================================================================== # Author: KTA # Description: Keep calling DialogDimisser() while there is a dialog present. # Parameters: pSpecifier - dialog descriptor. # Returns: 0 - Unsuccessful # -1 - There were no dialogs to dismiss # returnVal >= 1 - Successful All dialog were dismissed. Indicates # the number of dialogs that were idsmissed. # Examples: DialogHandler(); # Assumptions: None #======================================================================== # History: # KTA 3/24/94 Created # KTA 5/12/94 Changed the dialog window to either a movablemodal or a dialog. # KTA 9/21/94 Check to see if there was any statictext before concatenating strings # ML 11/22/94 Added error handling support # KTA 2/10/95 If no windows, don't iterate 10 times ######################################################################### TASK DialogHandler(pSpecifier := [window o:1 s:movablemodal c:false]!) begin ReturnVal := -1; # Default indicating no dialogs present StaticTextStr := ''; dialogCount := 0; for i := 1 to 10 # Only iterate 10 times begin wait(1); if (findwindow(pSpecifier, true) or findwindow([window o:1 s:dialog c:false]!, true)) begin dialogCount := dialogCount + 1; try match[staticText t:?theStaticText w:pSpecifier]; catch theError ExceptionDispatcher(theError); if(theStaticText) StaticTextStr := StaticTextStr + " / " + theStaticText; returnVal := DialogDismisser(, pSpecifier); end; else i := 10; end; if (returnVal > 0) returnVal := dialogCount; if(StaticTextStr) StaticTextStr := "Dialogs: " + StaticTextStr; return({returnVal, StaticTextStr}); end; # DialogHandler() ######################################################################### # DialogDismisser(pHowToDismiss, pSpecifier) #======================================================================== # Author: KTA # Description: Dismiss dialogs using one of several methods (or all) # Parameters: pHowToDismiss # 1 - Command - '.' # 2 - Escape key # 3 - 'Cancel' Button # 4 - 'No' button # 5 - 'Don't Save' button # 6 - 'OK' button # 7 - 'Quit' button # 8 - type 'Return Key' # String - # 'All' - all methods above # Any other string - SelectButton(<string>). # pSpecifier - dialog descriptor. # Returns: 0 - Unsuccessful # (non-zero) - Successful All dialog were dismissed. # Examples: DialogDismisser(); # Assumptions: None #======================================================================== # History: # KTA 3/24/94 Created # ML 11/22/94 Added error handling support # KTA 2/10/95 Call Findwindow with pBooleanFlag set # KTA 2/10/95 Optimized, removed edittext from specifiedDialog # ML 3/22/95 use _MatchBoolean() to check existence of pSpecifier # KTA 4/24/95 Changed case 9: pHowToDismiss to theButton (thanks - Mona Chow) # ML 11/21/95 add support for internationl ######################################################################### TASK DialogDismisser( pHowToDismiss := 'All', pSpecifier := [window o:1 c:false]!, pSpecifiedDialog := false) begin global gQuitString, gOKString, gNoString, gDontSaveString, gCancelString; returnval:=0; newTraits := {}; SpecifiedDialog := 0; if not(pSpecifiedDialog) begin if _MatchBoolean(pSpecifier) SpecifiedDialog:= FindWindow( pSpecifier); else if _MatchBoolean([window o:1 s:dialog]!) SpecifiedDialog := FindWindow([window o:1 s:dialog]); # GenericDialog ## Remove any EditTextFields if SpecifiedDialog begin for each item in SpecifiedDialog.k begin typeOfDescriptor := DescType(item); if not(typeOfDescriptor = 'editText') begin sizeofTraits := card(newTraits)+1; newTraits[sizeofTraits] := item; end; end; # for each item in SpecifiedDialog.k SpecifiedDialog.k := newTraits; end; # if SpecifiedDialog end; else SpecifiedDialog := pSpecifiedDialog; if (SpecifiedDialog) begin if (IsUndefined (gOKString)) okString := "OK"; else okString := gOKString; if (IsUndefined (gCancelString)) cancelString := "Cancel"; else cancelString := gCancelString; if (IsUndefined (gSaveString)) saveString := "Save"; else saveString := gSaveString; if (IsUndefined (gNoString)) noString := "No"; else noString := gNoString; if (IsUndefined (gQuitString)) quitString := "Quit"; else quitString := gQuitString; if(TypeOf(pHowToDismiss) = 'string') and not (pHowToDismiss = 'ALL') begin theButton := pHowToDismiss; pHowToDismiss := 9; end; Switch pHowToDismiss begin case 1: begin KeyEq('.'); if not (FindWindow(SpecifiedDialog, true)) return(1); end; case 2: begin SpecialKey(escapeKey, "Escape Key"); if not (FindWindow(SpecifiedDialog, true)) return(1); end; case 3: begin if(_matchBoolean ([button t:cancelString])) begin SelectButton(cancelString); if not (FindWindow(SpecifiedDialog, true)) return(1); end; end; case 4: begin if(_matchBoolean ([button t:noString])) begin SelectButton(noString); if not (FindWindow(SpecifiedDialog, true)) return(1); end; end; case 5: begin if (gDontSaveString) IsDontSaveBtn := _matchBoolean ([button t:gDontSaveString w:[window o:1]]!); else IsDontSaveBtn := _matchBoolean ([button t:/Don?t Save/ w:[window o:1]]!); if (IsDontSaveBtn) begin if (gDontSaveString) IsDontSaveBtn := _match ([button t:gDontSaveString w:[window o:1]]!,1); else IsDontSaveBtn := _match ([button t:/Don?t Save/ w:[window o:1]]!,1); DontSaveBtn := IsDontSaveBtn.t; SelectButton(DontSaveBtn); if not (FindWindow(SpecifiedDialog, true)) return(1); end; end; case 6: begin if(_matchBoolean ([button t:okString])) begin SelectButton(okString); if not (FindWindow(SpecifiedDialog, true)) return(1); end; end; case 7: begin if(_matchBoolean ([button t:quitString])) begin SelectButton(quitString); if not (FindWindow(SpecifiedDialog, true)) return(1); end; end; case 8: begin SpecialKey(returnKey, "return Key"); if not (FindWindow(SpecifiedDialog, true)) return(1); end; case 9: begin if(_matchBoolean ([button t:theButton])) SelectButton(theButton); if not (FindWindow(SpecifiedDialog, true)) return(1); end; case 'ALL': begin for i := 1 to 8 begin theReturn := DialogDismisser(i,,SpecifiedDialog); if(theReturn) return(theReturn); end; end; default: LogStr("Sorry, Can't seem to dismiss the dialog"); end; end; else returnVal := 1; Return(returnVal); end; # DialogDismisser() ######################################################################### # DismissDialog(pHowToDismiss, pSpecifier) #======================================================================= # Author: ML # Description: Generic dialog dismisser. # Assumptions: Window is style dialog and ordinality 1. # Parameters: pHowToDismiss - 1 type return key # {string} select button named {string} # Returns: 0 - dialog not dismissed # 1 - dialog sucessfully dismissed # Example: DismissDialog ('Cancel') #======================================================================= # History: # KTA 7/6/93 Added default value for the pHowToDismiss input parameter # KTA 7/7/93 Changed check to see if it actually dismissed the right dialog # KTA 7/19/93 changed pSpecifier so descriptor is not contained in a list # KTA 9/13/93 Added support for KeyEq('.') & better check to verfiy dialog # was dismissed. # ML 11/22/94 Added error handling support # JC 2/6/96 Changed all window .r (Rect) traits to .b (bound) traits. ######################################################################### TASK DismissDialog (pHowToDismiss := 1, pSpecifier := [window o:1 c:false]!) begin returnval:=0; SpecifiedDialog:= FindWindow( pSpecifier); if not (SpecifiedDialog) SpecifiedDialog := FindWindow([window o:1 s:dialog]); # GenericDialog if (SpecifiedDialog) begin if (pHowToDismiss = 1) SpecialKey(returnKey , "Return Key"); else if (TypeOf(pHowToDismiss) = 'string') begin if (pHowToDismiss = '.') keyEq('.'); else selectbutton (pHowToDismiss); end; wait(2); ## Give Dialog time to disappear ## Check to see if dialog is still present if not (_matchBoolean ([window t:SpecifiedDialog.t b:SpecifiedDialog.b c:SpecifiedDialog.c g:SpecifiedDialog.g z:SpecifiedDialog.z]!)) begin logstr('Dismissed dialog'); returnval:=1; end; else logstr('Unable to dismiss dialog'); end; # if SpecifiedDialog else begin logstr ('No dialog to dismiss'); returnval:=1; # Since there is no dialog to dismiss we were successful end; return(returnVal); end; # DismissDialog() #======================================================================= # Mouse action related tasks: #======================================================================= ######################################################################### # MoveRelativeToWindow(pHorizontalPixels, pVerticalPixels, pSpecifier,pMouseDown,pInset) #======================================================================== # Author: NJV # Description: This routine will calculate the window's rectangle # and add pHorizontalPixels and pVerticalPixels input parameters # to the rectangle's top-left coordinate point. It will then # move the mouse to that location. The window is # specified by the pSpecifier input parameter. If the # pSpecifier parameter is not present, the default # behavior will move relative to the frontmost document window. # Parameters: pHorizontalPixels - int representing left (pHorizontalPixels) coord # or List of points. # pVerticalPixels - int representing top (pVerticalPixels) coord # pSpecifier - holds title or ordinality of window # 0 matches first s:document c:true g:true window # pMouseDown - (see MoveMouse()) # pInset - inset from window rect for GetXYRandom # WhichCorner - Relative to which corner of the window # 1 - Top/Left # 2 - Bottom/Left # Returns: Nothing # Examples: MoveRelativeToWindow(12,25); # Assumptions: Assumes there is a window on the screen #======================================================================== # History: # KTA 7/6/93 Performance support: Call (gBeginTimer); # KTA 7/6/93 Move Performance Support into MoveMouse() # JC 2/7/96 Changed all window .r (Rect) traits to .b (bound) traits. ######################################################################### TASK MoveRelativeToWindow(pHorizontalPixels:= 'random', pVerticalPixels:= 'random', pSpecifier:=0,pMouseDown:=0,pInset:= {30,30,30,30}, WhichCorner := 1) begin returnVal := 0; # Init error condition if ( pHorizontalPixels='random') begin # user wants random mouse move xyRandom := GetRandomPointsRelativeToWindow(pInset, pSpecifier); pHorizontalPixels := xyRandom[1]; pVerticalPixels := xyRandom[2]; returnVal := xyRandom; end; theWind := FindWindow(pSpecifier); if theWind begin lvWindRect := theWind.b; if(whichCorner = 1) # Top/Left Corner begin lvX := lvWindRect[1]; lvY := lvWindRect[2]; end; else if(whichCorner = 2) # Bottom/Left begin lvX := lvWindRect[1]; lvY := lvWindRect[4]; end; else if(whichCorner = 3) # Bottom/Right begin lvX := lvWindRect[3]; lvY := lvWindRect[4]; end; else if(whichCorner = 4) # Top/Right begin lvX := lvWindRect[3]; lvY := lvWindRect[2]; end; # Handle PointList if (typeOF(pHorizontalPixels) = "list") # Need to move to a list of coordinates begin MoveMouse(pHorizontalPixels,{lvX,lvY},1,pMouseDown); # move to the calculated location returnVal := {lvX,lvY}; end; else begin lvFinalLeft := pHorizontalPixels + lvX; # calculate absolutely pHorizontalPixels lvFinalTop := pVerticalPixels + lvY; # calculate absolutely pVerticalPixels MoveMouse(lvFinalLeft,lvFinalTop,1,pMouseDown); # move to the calculated location returnVal := {lvFinalLeft,lvFinalTop}; end; end; return (returnVal); end; # MoveRelativeToWindow() ######################################################################### # MoveMouse(pHorizontalPixels, pVerticalPixels, pAbsolutely, pMouseDown) #======================================================================== # Author: DMM # Description: This routine will move the mouse pHorizontalPixels,pVerticalPixels # relative to its current location If pHorizontalPixels and # pVerticalPixels are absent or equal to "random", a random move is generated. # Parameters: pAbsolutely - 1 if move pAbsolutely, 0 if relative # pHorizontalPixels - horizontal distance in pixels to move mouse # pVerticalPixels - vertical distance in pixels to move mouse # if pHorizontalPixels and pVerticalPixels are absent # or := "random" then a random move is generated. # pAbsolutely - 1 to move to absolute location # 0 to move relative to current location # pMouseDown - 0 - don't hold mouse key down while moving # 1 - press mouse key down - move - release (can be a list of 1 element) # 2 - Click after moving - no mouse down during move # 3 - press mouse key down - move - don't release #pHorizontalPixels is List 3 - MultiDrag (pressmouse-move-move-move-releaseMouse) # 4 - move - release #pHorizontalPixels is List 5 - MultiClick (move-click-move-click) #pHorizontalPixels is List 6 - move-pressmouse-move-move-move-releaseMouse # Returns: Nothing #======================================================================== # History: # KTA 9/21/93 Added gPreMoveMouseHook # KTA 3/16/94 Added pMouseDown = 6 (move-pressmouse-move-move-move-releaseMouse) # KTA 3/16/94 Support for pMouseDown = 1 as a list of one element # KTA 4/13/94 Variable was named wrong which prevented moveRelativetoWindow # when pHorizontalPixels is a pointlist # ML 11/22/94 Added error handling support ######################################################################### TASK MoveMouse(pHorizontalPixels := 'random', pVerticalPixels := 'random', pAbsolutely := 1, pMouseDown := 0) begin if ( pHorizontalPixels='random') begin # user wants random mouse move xyRandom := getXYRandom(); pHorizontalPixels := xyRandom[1]; pVerticalPixels := xyRandom[2]; end; if ((pMouseDown = 1) or (pMouseDown = 3)) _PressMouse(); wait(1); # #### To Handle PointLists ##### if (typeOF(pHorizontalPixels) = "list") # Need to move to a list of coordinates begin pointList := pHorizontalPixels; xOffSet := 0; yOffSet := 0; if (typeOF(pVerticalPixels) = "list") # If its relative to window begin # We pass in pVerticalPixels as the offset of the window xOffSet := pVerticalPixels[1]; yOffSet := pVerticalPixels[2]; end; counter := 0; for each pairPoints in pointList begin Counter := Counter +1; if ((pMouseDown = 6) and (Counter = 2)) #move-pressmouse-move-move-move-releaseMouse _PressMouse(); nuX := pairPoints[1]; nuY := pairPoints[2]; pHorizontalPixels := nuX + xOffSet; # If relative to window offset pVerticalPixels := nuY + yOffSet; # otherwise the offset is 0 if(global gPreMoveMouseHook) Call(gPreMoveMouseHook); if (pAbsolutely) _move ('a', { pHorizontalPixels, pVerticalPixels }); else _move ('r', { pHorizontalPixels, pVerticalPixels }); if (pMouseDown = 5) # Click for Multiclick _click(); end; wait(1); if (pMouseDown = 1) or (pMouseDown = 3) or (pMouseDown = 6) # Finished MultiDrag _releaseMouse(); end; else begin if(global gPreMoveMouseHook) Call(gPreMoveMouseHook); if (pAbsolutely) begin _move ('a', { pHorizontalPixels, pVerticalPixels }); str := "Moved the mouse to absolute location ∂({pHorizontalPixels},{pVerticalPixels}∂)"; end; else begin _move ('r', { pHorizontalPixels, pVerticalPixels }); str := "Moved the mouse relative ∂({pHorizontalPixels},{pVerticalPixels}∂) to previous position"; end; wait(1); # release mouse if needed if ((pMouseDown = 1) or (pMouseDown = 4)) _ReleaseMouse(); # add mouse down to log string if needed if ((pMouseDown = 1) or (pMouseDown = 3) or (pMouseDown = 4)) str := "{str} with mouse button held down"; # click if needed if (pMouseDown = 2 ) begin _Click(); str := "{str} and clicked"; end; # log it LogStr(str); end; end; # MoveMouse() #======================================================================= # Keyboard action related tasks: #======================================================================= ######################################################################### # TypeStr(pTheString) #======================================================================== # Author: KTA # Description: This routine will type the string that is passed in as # the <pTheStringing>. # Parameters: pTheString - The string to be typed # Returns: Nothing # Note: If gTypeStrOverRide is defined as a task reference, it will have to handle # all actions all of the functionality of TypeStr since it is being overriden. #======================================================================== # History: # KTA 12/2/93 Added gTypeStrOverRide # ML 11/22/94 Added error handling support # MDF 05/03/96 Added gSwitchToUSHook task reference. This will support Intl # request for switching back to the "U.S." script when pTheString # contains precomposed doublebyte characters. ######################################################################### TASK TypeStr(pTheString :='') begin if (global gTypeStrOverRide) call (gTypeStrOverRide, pTheString); else begin if(global gSwitchToUSHook) call(gSwitchToUSHook); _type ({pTheString}); LogStr("Typed '{pTheString}'"); end; end; # TypeStr() ######################################################################### # TypeList(pStringList,pSpecialKey, pTypeFinalKey) #======================================================================== # Author: KTA # Description: This routine will type each item in the {pStringList} # and the selected special key, designated by the <pSpecialKey> # input parameter, after each item. If pTypeFinalKey = 0 the # special key will be suppressed after the last item. # Parameters: pStringList - list holding strings to type # pSpecialKey - integer representing key to type after the item has # been typed. # pSpecialKey := 0 Nothing # pSpecialKey := 1 (ReturnKey) # pSpecialKey := 2 (TabKey) # pSpecialKey := 3 (EnterKey) # pSpecialKey := 4 (UpArrowKey) # pTypeFinalKey - 1 to type special key after last item in <pStringList> # 0 to disable typing of last special key # Return Value: None # Examples: TypeList({'A','list', 'of items'},2); To type each item # and then the tabKey # Assumptions: None #======================================================================== # History: # ML 11/22/94 Added error handling support # MDF 04/24/96 Now checks for case where pSpecialKey = 0 (bug 1321298). # MDF 05/01/96 Added hooks gSetupTypeList and gCloseTypeList, per Intl req. ################################################################################ TASK TypeList(pStringList,pSpecialKey := 0, pTypeFinalKey := 0) begin theWholeList := card(pStringList); for numtimes := 1 to theWholeList begin if (global gSetupTypeList) call (gSetupTypeList); if(TypeOf(pSpecialKey) = 'integer') begin if (pSpecialKey = 0) KeyList := {'',''}; else if (pSpecialKey = 1) KeyList := {ReturnKey,' and the Return Key'}; else if (pSpecialKey = 2) KeyList := {TabKey,' and the Tab Key'}; else if (pSpecialKey = 3) KeyList := {EnterKey,' and the Enter Key'}; else if (pSpecialKey = 4) KeyList := {UpArrowKey,' and the Up Arrow Key'}; end; else KeyList := {pSpecialKey,' and some Special Key???'}; KeyName := KeyList[2]; Item := pStringList[numtimes]; _Type ({ Item }); if not (numtimes = theWholeList) begin _Type ({KeyList[1]}); end; else if(pTypeFinalKey) _Type ({KeyList[1]}); else KeyName := ''; LogStr("Typed '{item}'{KeyName}"); end; if (global gCloseTypeList) # hook for Intl call (gCloseTypeList); end; # TypeList() ######################################################################### # SpecialKey( pTheKey, pKeyName, pNumTimes ) #======================================================================== # Author: KTA # Description: This routine will type whatever SpecialKey is entered # However it will only log the name of the special character # if the special key name is also passed in as a String in # the pKeyName parameter. # Parameters: pTheKey - the VU key-word for the special key to be typed # (i.e. ReturnKey, TabKey, EnterKey, etc.) # pKeyName - the string name of the special key # pNumTimes - number of times to type the special key (default = 1) # Returns: Nothing # Examples: SpecialKey(TabKey,"TabKey"); #======================================================================== # History: # KTA 7/6/93 Performance support: Call (gBeginTimer); # KTA 9/21/93 Changed gBeginTimer to gPreSpecialKeyHook # KTA 11/18/93 Log prior to performing the action # ML 11/22/94 Added error handling support ######################################################################### TASK SpecialKey( pTheKey, pKeyName := "", pNumTimes := 1 ) begin StrExt := ""; if (pNumTimes <> 1) StrExt := "- ({pNumTimes}) times"; if (pKeyName ="") LogStr("Typing some special key {StrExt}"); else LogStr ("Typing {pKeyName} {StrExt}"); for x := 1 to pNumTimes begin if (global gPreSpecialKeyHook) Call (gPreSpecialKeyHook); _type ({ pTheKey }); end; end; # SpecialKey()